Author: aandrejevic Date: Wed Nov 13 22:33:37 2013 New Revision: 60984
URL: http://svn.reactos.org/svn/reactos?rev=60984&view=rev Log: [FAST486] XADD: Fix the order of operations. POP <modrm>: The value must be popped from the stack before parsing the Mod-Reg-R/M, because of the "POP DWORD [ESP]" case.
Modified: branches/ntvdm/lib/fast486/common.inl branches/ntvdm/lib/fast486/extraops.c branches/ntvdm/lib/fast486/opgroups.c
Modified: branches/ntvdm/lib/fast486/common.inl URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/common.inl?rev... ============================================================================== --- branches/ntvdm/lib/fast486/common.inl [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/common.inl [iso-8859-1] Wed Nov 13 22:33:37 2013 @@ -326,7 +326,7 @@ BOOLEAN Size = State->SegmentRegs[FAST486_REG_SS].Size;
/* The OPSIZE prefix toggles the size */ - if (State->PrefixFlags & FAST486_PREFIX_OPSIZE) Size = !Size; + TOGGLE_OPSIZE(Size);
if (Size) {
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] Wed Nov 13 22:33:37 2013 @@ -2032,15 +2032,15 @@ State->Flags.Sf = ((Result & SIGN_FLAG_LONG) != 0); State->Flags.Pf = Fast486CalculateParity(Result);
+ /* Write the old value of the destination to the source */ + if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, Destination)) + { + /* Exception occurred */ + return FALSE; + } + /* Write the sum to the destination */ if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, Result)) - { - /* Exception occurred */ - return FALSE; - } - - /* Write the old value of the destination to the source */ - if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, TRUE, Destination)) { /* Exception occurred */ return FALSE; @@ -2071,15 +2071,15 @@ State->Flags.Sf = ((Result & SIGN_FLAG_WORD) != 0); State->Flags.Pf = Fast486CalculateParity(Result);
+ /* Write the old value of the destination to the source */ + if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, Destination)) + { + /* Exception occurred */ + return FALSE; + } + /* Write the sum to the destination */ if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, Result)) - { - /* Exception occurred */ - return FALSE; - } - - /* Write the old value of the destination to the source */ - if (!Fast486WriteModrmWordOperands(State, &ModRegRm, TRUE, Destination)) { /* Exception occurred */ return FALSE;
Modified: branches/ntvdm/lib/fast486/opgroups.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opgroups.c?rev... ============================================================================== --- branches/ntvdm/lib/fast486/opgroups.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opgroups.c [iso-8859-1] Wed Nov 13 22:33:37 2013 @@ -486,9 +486,19 @@ TOGGLE_OPSIZE(OperandSize); TOGGLE_ADSIZE(AddressSize);
+ /* Pop a value from the stack - this must be done first */ + if (!Fast486StackPop(State, &Value)) + { + /* Exception occurred */ + return FALSE; + } + if (!Fast486ParseModRegRm(State, AddressSize, &ModRegRm)) { - /* Exception occurred */ + /* 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; }
@@ -496,13 +506,6 @@ { /* Invalid */ Fast486Exception(State, FAST486_EXCEPTION_UD); - return FALSE; - } - - /* Pop a value from the stack */ - if (!Fast486StackPop(State, &Value)) - { - /* Exception occurred */ return FALSE; }