[SOFT386]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 21 Sep 2013 00:41:41 +0000 (00:41 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 21 Sep 2013 00:41:41 +0000 (00:41 +0000)
Implement external stack modification.
[NTVDM]
Implement EmulatorSetStack for NEW_EMULATOR.

svn path=/branches/ntvdm/; revision=60257

include/reactos/libs/soft386/soft386.h
lib/soft386/soft386.c
subsystems/ntvdm/emulator.c

index 50e23a2..f3412ea 100644 (file)
@@ -341,6 +341,10 @@ VOID
 NTAPI
 Soft386ExecuteAt(PSOFT386_STATE State, USHORT Segment, ULONG Offset);
 
+VOID
+NTAPI
+Soft386SetStack(PSOFT386_STATE State, USHORT Segment, ULONG Offset);
+
 #endif // _SOFT386_H_
 
 /* EOF */
index 76c5f58..08cba1a 100644 (file)
@@ -270,4 +270,20 @@ Soft386ExecuteAt(PSOFT386_STATE State, USHORT Segment, ULONG Offset)
     State->InstPtr.Long = Offset;
 }
 
+VOID
+NTAPI
+Soft386SetStack(PSOFT386_STATE State, USHORT Segment, ULONG Offset)
+{
+    /* Load the new SS */
+    if (!Soft386LoadSegment(State, SOFT386_REG_SS, Segment))
+    {
+        /* An exception occurred, let the handler execute instead */
+        return;
+    }
+
+    /* Set the new SP */
+    State->GeneralRegs[SOFT386_REG_ESP].Long = Offset;
+}
+
+
 /* EOF */
index c41d1c6..6fba6da 100644 (file)
@@ -429,7 +429,7 @@ VOID EmulatorSetStack(WORD Segment, DWORD Offset)
     /* Call the softx86 API */
     softx86_set_stack_ptr(&EmulatorContext, Segment, Offset);
 #else
-    // TODO: NOT IMPLEMENTED
+    Soft386SetStack(&EmulatorContext, Segment, Offset);
 #endif
 }