[FAST486]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Fri, 21 Nov 2014 09:46:57 +0000 (09:46 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Fri, 21 Nov 2014 09:46:57 +0000 (09:46 +0000)
Attempt to write the value to the stack before subtracting from the actual ESP register
in Fast486StackPush.

svn path=/trunk/; revision=65441

reactos/lib/fast486/common.inl

index 381ed03..ed811ff 100644 (file)
@@ -317,15 +317,19 @@ Fast486StackPush(PFAST486_STATE State,
             return FALSE;
         }
 
+        /* Store the value in SS:[ESP - 4] */
+        if (!Fast486WriteMemory(State,
+                                FAST486_REG_SS,
+                                State->GeneralRegs[FAST486_REG_ESP].Long - sizeof(ULONG),
+                                &Value,
+                                sizeof(ULONG)))
+        {
+            /* Exception occurred */
+            return FALSE;
+        }
+
         /* Subtract ESP by 4 */
         State->GeneralRegs[FAST486_REG_ESP].Long -= sizeof(ULONG);
-
-        /* Store the value in SS:ESP */
-        return Fast486WriteMemory(State,
-                                  FAST486_REG_SS,
-                                  State->GeneralRegs[FAST486_REG_ESP].Long,
-                                  &Value,
-                                  sizeof(ULONG));
     }
     else
     {
@@ -339,16 +343,22 @@ Fast486StackPush(PFAST486_STATE State,
             return FALSE;
         }
 
+        /* Store the value in SS:[SP - 2] */
+        if (!Fast486WriteMemory(State,
+                                FAST486_REG_SS,
+                                LOWORD(State->GeneralRegs[FAST486_REG_ESP].LowWord - sizeof(USHORT)),
+                                &ShortValue,
+                                sizeof(USHORT)))
+        {
+            /* Exception occurred */
+            return FALSE;
+        }
+
         /* Subtract SP by 2 */
         State->GeneralRegs[FAST486_REG_ESP].LowWord -= sizeof(USHORT);
-
-        /* Store the value in SS:SP */
-        return Fast486WriteMemory(State,
-                                  FAST486_REG_SS,
-                                  State->GeneralRegs[FAST486_REG_ESP].LowWord,
-                                  &ShortValue,
-                                  sizeof(USHORT));
     }
+
+    return TRUE;
 }
 
 FORCEINLINE