Author: aandrejevic Date: Sun Aug 25 12:17:24 2013 New Revision: 59816
URL: http://svn.reactos.org/svn/reactos?rev=59816&view=rev Log: [SOFT386] Implement the following instructions: PUSH reg16/reg32 POP reg16/reg32
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] Sun Aug 25 12:17:24 2013 @@ -104,22 +104,22 @@ Soft386OpcodeDecrement, Soft386OpcodeDecrement, Soft386OpcodeDecrement, - NULL, // TODO: OPCODE 0x50 NOT SUPPORTED - NULL, // TODO: OPCODE 0x51 NOT SUPPORTED - NULL, // TODO: OPCODE 0x52 NOT SUPPORTED - NULL, // TODO: OPCODE 0x53 NOT SUPPORTED - NULL, // TODO: OPCODE 0x54 NOT SUPPORTED - NULL, // TODO: OPCODE 0x55 NOT SUPPORTED - NULL, // TODO: OPCODE 0x56 NOT SUPPORTED - NULL, // TODO: OPCODE 0x57 NOT SUPPORTED - NULL, // TODO: OPCODE 0x58 NOT SUPPORTED - NULL, // TODO: OPCODE 0x59 NOT SUPPORTED - NULL, // TODO: OPCODE 0x5A NOT SUPPORTED - NULL, // TODO: OPCODE 0x5B NOT SUPPORTED - NULL, // TODO: OPCODE 0x5C NOT SUPPORTED - NULL, // TODO: OPCODE 0x5D NOT SUPPORTED - NULL, // TODO: OPCODE 0x5E NOT SUPPORTED - NULL, // TODO: OPCODE 0x5F NOT SUPPORTED + Soft386OpcodePushReg, + Soft386OpcodePushReg, + Soft386OpcodePushReg, + Soft386OpcodePushReg, + Soft386OpcodePushReg, + Soft386OpcodePushReg, + Soft386OpcodePushReg, + Soft386OpcodePushReg, + Soft386OpcodePopReg, + Soft386OpcodePopReg, + Soft386OpcodePopReg, + Soft386OpcodePopReg, + Soft386OpcodePopReg, + Soft386OpcodePopReg, + Soft386OpcodePopReg, + Soft386OpcodePopReg, NULL, // TODO: OPCODE 0x60 NOT SUPPORTED NULL, // TODO: OPCODE 0x61 NOT SUPPORTED NULL, // TODO: OPCODE 0x62 NOT SUPPORTED @@ -534,3 +534,55 @@ /* Return success */ return TRUE; } + +BOOLEAN +FASTCALL +Soft386OpcodePushReg(PSOFT386_STATE State, UCHAR Opcode) +{ + if ((State->PrefixFlags != SOFT386_PREFIX_OPSIZE) + && (State->PrefixFlags != 0)) + { + /* Invalid prefix */ + Soft386Exception(State, SOFT386_EXCEPTION_UD); + return FALSE; + } + + /* Make sure this is the right instruction */ + ASSERT((Opcode & 0xF8) == 0x50); + + /* Call the internal function */ + return Soft386StackPush(State, State->GeneralRegs[Opcode & 0x07].Long); +} + +BOOLEAN +FASTCALL +Soft386OpcodePopReg(PSOFT386_STATE State, UCHAR Opcode) +{ + ULONG Value; + BOOLEAN Size = State->SegmentRegs[SOFT386_REG_SS].Size; + + if (State->PrefixFlags == SOFT386_PREFIX_OPSIZE) + { + /* The OPSIZE prefix toggles the size */ + Size = !Size; + } + else if (State->PrefixFlags != 0) + { + /* Invalid prefix */ + Soft386Exception(State, SOFT386_EXCEPTION_UD); + return FALSE; + } + + /* Make sure this is the right instruction */ + ASSERT((Opcode & 0xF8) == 0x58); + + /* Call the internal function */ + if (!Soft386StackPop(State, &Value)) return FALSE; + + /* Store the value */ + if (Size) State->GeneralRegs[Opcode & 0x07].Long = Value; + else State->GeneralRegs[Opcode & 0x07].LowWord = Value; + + /* 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] Sun Aug 25 12:17:24 2013 @@ -47,4 +47,20 @@ UCHAR Opcode );
+BOOLEAN +FASTCALL +Soft386OpcodePushReg +( + PSOFT386_STATE State, + UCHAR Opcode +); + +BOOLEAN +FASTCALL +Soft386OpcodePopReg +( + PSOFT386_STATE State, + UCHAR Opcode +); + #endif // _OPCODES_H_