[SOFT386]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Wed, 9 Oct 2013 21:48:52 +0000 (21:48 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Wed, 9 Oct 2013 21:48:52 +0000 (21:48 +0000)
Implement an API for external segment modification.
[NTVDM]
Implement EmulatorSetRegister for NEW_EMULATOR.

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

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

index 9c07bc3..5b4acfe 100644 (file)
@@ -369,6 +369,15 @@ VOID
 NTAPI
 Soft386SetStack(PSOFT386_STATE State, USHORT Segment, ULONG Offset);
 
+VOID
+NTAPI
+Soft386SetSegment
+(
+    PSOFT386_STATE State,
+    SOFT386_SEG_REGS Segment,
+    USHORT Selector
+);
+
 #endif // _SOFT386_H_
 
 /* EOF */
index 396cb6e..1415473 100644 (file)
@@ -306,5 +306,14 @@ Soft386SetStack(PSOFT386_STATE State, USHORT Segment, ULONG Offset)
     State->GeneralRegs[SOFT386_REG_ESP].Long = Offset;
 }
 
+VOID
+NTAPI
+Soft386SetSegment(PSOFT386_STATE State,
+                  SOFT386_SEG_REGS Segment,
+                  USHORT Selector)
+{
+    /* Call the internal function */
+    Soft386LoadSegment(State, Segment, Selector);
+}
 
 /* EOF */
index b1bf563..e3b8027 100644 (file)
@@ -521,16 +521,23 @@ ULONG EmulatorGetProgramCounter(VOID)
 VOID EmulatorSetRegister(ULONG Register, ULONG Value)
 {
 #ifndef NEW_EMULATOR
-    if (Register < EMULATOR_REG_CS)
+    if (Register < EMULATOR_REG_ES)
     {
         EmulatorContext.state->general_reg[Register].val = Value;
     }
     else
     {
-        EmulatorContext.state->segment_reg[Register - EMULATOR_REG_ES].val = (WORD)Value;
+        EmulatorContext.state->segment_reg[Register - EMULATOR_REG_ES].val = (USHORT)Value;
     }
 #else
-    // TODO: NOT IMPLEMENTED
+    if (Register < EMULATOR_REG_ES)
+    {
+        EmulatorContext.GeneralRegs[Register].Long = Value;
+    }
+    else
+    {
+        Soft386SetSegment(&EmulatorContext, Register - EMULATOR_REG_ES, (USHORT)Value);
+    }
 #endif
 }
 
@@ -596,7 +603,7 @@ VOID EmulatorStep(VOID)
     }
 #else
     /* Dump the state for debugging purposes */
-    Soft386DumpState(&EmulatorContext);
+    // Soft386DumpState(&EmulatorContext);
 
     /* Execute the next instruction */
     Soft386StepInto(&EmulatorContext);