mirror of
https://github.com/reactos/reactos.git
synced 2025-05-25 20:18:22 +00:00
[FAST486]
Fix the 3-byte IMUL instruction. If the operand size is 16-bit, the result should be written in 16-bit too. svn path=/branches/ntvdm/; revision=60963
This commit is contained in:
parent
cf559336a1
commit
0aed89f779
1 changed files with 21 additions and 11 deletions
|
@ -3595,7 +3595,6 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeImulModrmImm)
|
||||||
BOOLEAN OperandSize, AddressSize;
|
BOOLEAN OperandSize, AddressSize;
|
||||||
FAST486_MOD_REG_RM ModRegRm;
|
FAST486_MOD_REG_RM ModRegRm;
|
||||||
LONG Multiplier;
|
LONG Multiplier;
|
||||||
LONGLONG Product;
|
|
||||||
|
|
||||||
/* Make sure this is the right instruction */
|
/* Make sure this is the right instruction */
|
||||||
ASSERT((Opcode & 0xFD) == 0x69);
|
ASSERT((Opcode & 0xFD) == 0x69);
|
||||||
|
@ -3658,6 +3657,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeImulModrmImm)
|
||||||
if (OperandSize)
|
if (OperandSize)
|
||||||
{
|
{
|
||||||
LONG RegValue, Multiplicand;
|
LONG RegValue, Multiplicand;
|
||||||
|
LONGLONG Product;
|
||||||
|
|
||||||
/* Read the operands */
|
/* Read the operands */
|
||||||
if (!Fast486ReadModrmDwordOperands(State,
|
if (!Fast486ReadModrmDwordOperands(State,
|
||||||
|
@ -3671,10 +3671,20 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeImulModrmImm)
|
||||||
|
|
||||||
/* Multiply */
|
/* Multiply */
|
||||||
Product = (LONGLONG)Multiplicand * (LONGLONG)Multiplier;
|
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
|
else
|
||||||
{
|
{
|
||||||
SHORT RegValue, Multiplicand;
|
SHORT RegValue, Multiplicand;
|
||||||
|
LONG Product;
|
||||||
|
|
||||||
/* Read the operands */
|
/* Read the operands */
|
||||||
if (!Fast486ReadModrmWordOperands(State,
|
if (!Fast486ReadModrmWordOperands(State,
|
||||||
|
@ -3687,17 +3697,17 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeImulModrmImm)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Multiply */
|
/* Multiply */
|
||||||
Product = (LONGLONG)Multiplicand * (LONGLONG)Multiplier;
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FAST486_OPCODE_HANDLER(Fast486OpcodePushByteImm)
|
FAST486_OPCODE_HANDLER(Fast486OpcodePushByteImm)
|
||||||
|
|
Loading…
Reference in a new issue