Author: aandrejevic Date: Mon Nov 11 00:10:46 2013 New Revision: 60929
URL: http://svn.reactos.org/svn/reactos?rev=60929&view=rev Log: [FAST486] Implement the two operand version of IMUL.
Modified: branches/ntvdm/lib/fast486/extraops.c branches/ntvdm/lib/fast486/extraops.h
Modified: branches/ntvdm/lib/fast486/extraops.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.c?rev... ============================================================================== --- branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] Mon Nov 11 00:10:46 2013 @@ -212,7 +212,7 @@ NULL, // TODO: OPCODE 0xAC NOT IMPLEMENTED NULL, // TODO: OPCODE 0xAD NOT IMPLEMENTED NULL, // TODO: OPCODE 0xAE NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xAF NOT IMPLEMENTED + Fast486ExtOpcodeImul, Fast486ExtOpcodeCmpXchgByte, Fast486ExtOpcodeCmpXchg, NULL, // TODO: OPCODE 0xB2 NOT IMPLEMENTED @@ -712,6 +712,70 @@ return TRUE; }
+FAST486_OPCODE_HANDLER(Fast486ExtOpcodeImul) +{ + BOOLEAN OperandSize, AddressSize; + FAST486_MOD_REG_RM ModRegRm; + + OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size; + + /* Get the operands */ + if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) + { + /* Exception occurred */ + return FALSE; + } + + if (OperandSize) + { + LONG Source, Destination; + LONGLONG Result; + + /* Read the operands */ + if (!Fast486ReadModrmDwordOperands(State, + &ModRegRm, + (PULONG)&Destination, + (PULONG)&Source)) + { + /* Exception occurred */ + return FALSE; + } + + /* Calculate the result */ + Result = (LONGLONG)Source * (LONGLONG)Destination; + + /* Update the flags */ + State->Flags.Cf = State->Flags.Of = ((Result < -2147483648LL) || (Result > 2147483647LL)); + + /* Write back the result */ + return Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, (ULONG)((LONG)Result)); + } + else + { + SHORT Source, Destination; + LONG Result; + + /* Read the operands */ + if (!Fast486ReadModrmWordOperands(State, + &ModRegRm, + (PUSHORT)&Destination, + (PUSHORT)&Source)) + { + /* Exception occurred */ + return FALSE; + } + + /* Calculate the result */ + Result = (LONG)Source * (LONG)Destination; + + /* Update the flags */ + State->Flags.Cf = State->Flags.Of = ((Result < -32768) || (Result > 32767)); + + /* Write back the result */ + return Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, (USHORT)((SHORT)Result)); + } +} + FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchgByte) { FAST486_MOD_REG_RM ModRegRm;
Modified: branches/ntvdm/lib/fast486/extraops.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.h?rev... ============================================================================== --- branches/ntvdm/lib/fast486/extraops.h [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.h [iso-8859-1] Mon Nov 11 00:10:46 2013 @@ -37,6 +37,7 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodePushGs); FAST486_OPCODE_HANDLER(Fast486ExtOpcodePopGs); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBts); +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeImul); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchgByte); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeCmpXchg); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBtr);