Are you sure this is the correct order of execution?
The instruction is
 documented as first lowering the stack pointer, then writing to the new
 location.
 If a stack exception occurs, you might have esp off by 4.
 Am 21.11.2014 10:46, schrieb aandrejevic(a)svn.reactos.org:
 Author: aandrejevic
Date: Fri Nov 21 09:46:57 2014
New Revision: 65441
URL: 
http://svn.reactos.org/svn/reactos?rev=65441&view=rev
Log:
[FAST486]
Attempt to write the value to the stack before subtracting from the actual ESP register
in Fast486StackPush.
Modified:
     trunk/reactos/lib/fast486/common.inl
Modified: trunk/reactos/lib/fast486/common.inl
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.inl?rev…
==============================================================================
--- trunk/reactos/lib/fast486/common.inl        [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/common.inl        [iso-8859-1] Fri Nov 21 09:46:57 2014
@@ -317,15 +317,19 @@
              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 @@
              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
 
 _______________________________________________
 Ros-dev mailing list
 Ros-dev(a)reactos.org