State->Flags.Sf = ((Result & SIGN_FLAG_LONG) != 0);
State->Flags.Pf = Fast486CalculateParity(Result);
- /* Write the sum to the destination */
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Result))
+ /* Write the old value of the destination to the source */
+ if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, Destination))
{
/* Exception occurred */
return FALSE;
}
- /* Write the old value of the destination to the source */
- if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, Destination))
+ /* Write the sum to the destination */
+ if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Result))
{
/* Exception occurred */
return FALSE;
State->Flags.Sf = ((Result & SIGN_FLAG_WORD) != 0);
State->Flags.Pf = Fast486CalculateParity(Result);
- /* Write the sum to the destination */
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Result))
+ /* Write the old value of the destination to the source */
+ if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, Destination))
{
/* Exception occurred */
return FALSE;
}
- /* Write the old value of the destination to the source */
- if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, Destination))
+ /* Write the sum to the destination */
+ if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Result))
{
/* Exception occurred */
return FALSE;
TOGGLE_OPSIZE(OperandSize);
TOGGLE_ADSIZE(AddressSize);
- if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
+ /* Pop a value from the stack - this must be done first */
+ if (!Fast486StackPop(State, &Value))
{
/* Exception occurred */
return FALSE;
}
- if (ModRegRm.Register != 0)
+ if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm))
{
- /* Invalid */
- Fast486Exception(State, FAST486_EXCEPTION_UD);
+ /* Exception occurred - restore SP */
+ if (OperandSize) State->GeneralRegs[FAST486_REG_ESP].Long += sizeof(ULONG);
+ else State->GeneralRegs[FAST486_REG_ESP].LowWord += sizeof(USHORT);
+
return FALSE;
}
- /* Pop a value from the stack */
- if (!Fast486StackPop(State, &Value))
+ if (ModRegRm.Register != 0)
{
- /* Exception occurred */
+ /* Invalid */
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
return FALSE;
}