Author: aandrejevic Date: Wed Aug 28 17:52:21 2013 New Revision: 59856
URL: http://svn.reactos.org/svn/reactos?rev=59856&view=rev Log: [SOFT386] Implement short conditional jump opcodes.
Modified: branches/ntvdm/lib/soft386/opcodes.c branches/ntvdm/lib/soft386/opcodes.h
Modified: branches/ntvdm/lib/soft386/opcodes.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opcodes.c?rev=... ============================================================================== --- branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] Wed Aug 28 17:52:21 2013 @@ -136,22 +136,22 @@ NULL, // TODO: OPCODE 0x6D NOT SUPPORTED NULL, // TODO: OPCODE 0x6E NOT SUPPORTED NULL, // TODO: OPCODE 0x6F NOT SUPPORTED - NULL, // TODO: OPCODE 0x70 NOT SUPPORTED - NULL, // TODO: OPCODE 0x71 NOT SUPPORTED - NULL, // TODO: OPCODE 0x72 NOT SUPPORTED - NULL, // TODO: OPCODE 0x73 NOT SUPPORTED - NULL, // TODO: OPCODE 0x74 NOT SUPPORTED - NULL, // TODO: OPCODE 0x75 NOT SUPPORTED - NULL, // TODO: OPCODE 0x76 NOT SUPPORTED - NULL, // TODO: OPCODE 0x77 NOT SUPPORTED - NULL, // TODO: OPCODE 0x78 NOT SUPPORTED - NULL, // TODO: OPCODE 0x79 NOT SUPPORTED - NULL, // TODO: OPCODE 0x7A NOT SUPPORTED - NULL, // TODO: OPCODE 0x7B NOT SUPPORTED - NULL, // TODO: OPCODE 0x7C NOT SUPPORTED - NULL, // TODO: OPCODE 0x7D NOT SUPPORTED - NULL, // TODO: OPCODE 0x7E NOT SUPPORTED - NULL, // TODO: OPCODE 0x7F NOT SUPPORTED + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, + Soft386OpcodeShortConditionalJmp, NULL, // TODO: OPCODE 0x80 NOT SUPPORTED NULL, // TODO: OPCODE 0x81 NOT SUPPORTED NULL, // TODO: OPCODE 0x82 NOT SUPPORTED @@ -648,3 +648,95 @@
return TRUE; } + +BOOLEAN +FASTCALL +Soft386OpcodeShortConditionalJmp(PSOFT386_STATE State, UCHAR Opcode) +{ + BOOLEAN Jump = FALSE; + CHAR Offset = 0; + + /* Make sure this is the right instruction */ + ASSERT((Opcode & 0xF0) == 0x70); + + /* Fetch the offset */ + if (!Soft386FetchByte(State, (PUCHAR)&Offset)) + { + /* An exception occurred */ + return FALSE; + } + + switch ((Opcode & 0x0F) >> 1) + { + /* JO / JNO */ + case 0: + { + Jump = State->Flags.Of; + break; + } + + /* JC / JNC */ + case 1: + { + Jump = State->Flags.Cf; + break; + } + + /* JZ / JNZ */ + case 2: + { + Jump = State->Flags.Zf; + break; + } + + /* JBE / JNBE */ + case 3: + { + Jump = State->Flags.Cf || State->Flags.Zf; + break; + } + + /* JS / JNS */ + case 4: + { + Jump = State->Flags.Sf; + break; + } + + /* JP / JNP */ + case 5: + { + Jump = State->Flags.Pf; + break; + } + + /* JL / JNL */ + case 6: + { + Jump = State->Flags.Sf != State->Flags.Of; + break; + } + + /* JLE / JNLE */ + case 7: + { + Jump = (State->Flags.Sf != State->Flags.Of) || State->Flags.Zf; + break; + } + } + + if ((Opcode & 0xF0) & 1) + { + /* Invert the result */ + Jump = !Jump; + } + + if (Jump) + { + /* Move the instruction pointer */ + State->InstPtr.Long += Offset; + } + + /* Return success */ + return TRUE; +}
Modified: branches/ntvdm/lib/soft386/opcodes.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opcodes.h?rev=... ============================================================================== --- branches/ntvdm/lib/soft386/opcodes.h [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/opcodes.h [iso-8859-1] Wed Aug 28 17:52:21 2013 @@ -79,4 +79,12 @@ UCHAR Opcode );
+BOOLEAN +FASTCALL +Soft386OpcodeShortConditionalJmp +( + PSOFT386_STATE State, + UCHAR Opcode +); + #endif // _OPCODES_H_