Author: aandrejevic Date: Tue Nov 12 18:21:30 2013 New Revision: 60963
URL: http://svn.reactos.org/svn/reactos?rev=60963&view=rev Log: [FAST486] Fix the 3-byte IMUL instruction. If the operand size is 16-bit, the result should be written in 16-bit too.
Modified: branches/ntvdm/lib/fast486/opcodes.c
Modified: branches/ntvdm/lib/fast486/opcodes.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opcodes.c?rev=... ============================================================================== --- branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] Tue Nov 12 18:21:30 2013 @@ -3595,7 +3595,6 @@ BOOLEAN OperandSize, AddressSize; FAST486_MOD_REG_RM ModRegRm; LONG Multiplier; - LONGLONG Product;
/* Make sure this is the right instruction */ ASSERT((Opcode & 0xFD) == 0x69); @@ -3658,6 +3657,7 @@ if (OperandSize) { LONG RegValue, Multiplicand; + LONGLONG Product;
/* Read the operands */ if (!Fast486ReadModrmDwordOperands(State, @@ -3671,10 +3671,20 @@
/* Multiply */ Product = (LONGLONG)Multiplicand * (LONGLONG)Multiplier; + + /* Check for carry/overflow */ + State->Flags.Cf = State->Flags.Of = ((Product < MINLONG) || (Product > MAXLONG)); + + /* Write-back the result */ + return Fast486WriteModrmDwordOperands(State, + &ModRegRm, + TRUE, + (ULONG)((LONG)Product)); } else { SHORT RegValue, Multiplicand; + LONG Product;
/* Read the operands */ if (!Fast486ReadModrmWordOperands(State, @@ -3687,17 +3697,17 @@ }
/* Multiply */ - Product = (LONGLONG)Multiplicand * (LONGLONG)Multiplier; - } - - /* Check for carry/overflow */ - State->Flags.Cf = State->Flags.Of = ((Product < MINLONG) || (Product > MAXLONG)); - - /* Write-back the result */ - return Fast486WriteModrmDwordOperands(State, - &ModRegRm, - TRUE, - (ULONG)((LONG)Product)); + Product = (LONG)Multiplicand * (LONG)Multiplier; + + /* Check for carry/overflow */ + State->Flags.Cf = State->Flags.Of = ((Product < MINSHORT) || (Product > MAXSHORT)); + + /* Write-back the result */ + return Fast486WriteModrmWordOperands(State, + &ModRegRm, + TRUE, + (USHORT)((SHORT)Product)); + } }
FAST486_OPCODE_HANDLER(Fast486OpcodePushByteImm)