[FAST486]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sun, 10 Nov 2013 23:34:34 +0000 (23:34 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sun, 10 Nov 2013 23:34:34 +0000 (23:34 +0000)
Don't mix up ADSIZE and OPSIZE.

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

lib/fast486/opcodes.c

index 8ba3956..4eb2e6b 100644 (file)
@@ -5223,15 +5223,15 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeMovEaxOffset)
 
 FAST486_OPCODE_HANDLER(Fast486OpcodeMovOffsetAl)
 {
-    BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size;
+    BOOLEAN AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
     ULONG Offset;
 
     /* Make sure this is the right instruction */
     ASSERT(Opcode == 0xA2);
 
-    TOGGLE_OPSIZE(Size);
+    TOGGLE_ADSIZE(AddressSize);
 
-    if (Size)
+    if (AddressSize)
     {
         if (!Fast486FetchDword(State, &Offset))
         {
@@ -5263,14 +5263,17 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeMovOffsetAl)
 
 FAST486_OPCODE_HANDLER(Fast486OpcodeMovOffsetEax)
 {
-    BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size;
+    BOOLEAN OperandSize, AddressSize;
+    
+    OperandSize = AddressSize = State->SegmentRegs[FAST486_REG_CS].Size;
 
     /* Make sure this is the right instruction */
     ASSERT(Opcode == 0xA3);
 
-    TOGGLE_OPSIZE(Size);
+    TOGGLE_OPSIZE(OperandSize);
+    TOGGLE_ADSIZE(AddressSize);
 
-    if (Size)
+    if (AddressSize)
     {
         ULONG Offset;
 
@@ -5281,12 +5284,24 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeMovOffsetEax)
         }
 
         /* Write to memory */
-        return Fast486WriteMemory(State,
-                                  (State->PrefixFlags & FAST486_PREFIX_SEG) ?
-                                  State->SegmentOverride : FAST486_REG_DS,
-                                  Offset,
-                                  &State->GeneralRegs[FAST486_REG_EAX].Long,
-                                  sizeof(ULONG));
+        if (OperandSize)
+        {
+            return Fast486WriteMemory(State,
+                                      (State->PrefixFlags & FAST486_PREFIX_SEG) ?
+                                      State->SegmentOverride : FAST486_REG_DS,
+                                      Offset,
+                                      &State->GeneralRegs[FAST486_REG_EAX].Long,
+                                      sizeof(ULONG));
+        }
+        else
+        {
+            return Fast486WriteMemory(State,
+                                      (State->PrefixFlags & FAST486_PREFIX_SEG) ?
+                                      State->SegmentOverride : FAST486_REG_DS,
+                                      Offset,
+                                      &State->GeneralRegs[FAST486_REG_EAX].LowWord,
+                                      sizeof(USHORT));
+        }
     }
     else
     {
@@ -5299,12 +5314,24 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeMovOffsetEax)
         }
 
         /* Write to memory */
-        return Fast486WriteMemory(State,
-                                  (State->PrefixFlags & FAST486_PREFIX_SEG) ?
-                                  State->SegmentOverride : FAST486_REG_DS,
-                                  Offset,
-                                  &State->GeneralRegs[FAST486_REG_EAX].LowWord,
-                                  sizeof(USHORT));
+        if (OperandSize)
+        {
+            return Fast486WriteMemory(State,
+                                      (State->PrefixFlags & FAST486_PREFIX_SEG) ?
+                                      State->SegmentOverride : FAST486_REG_DS,
+                                      Offset,
+                                      &State->GeneralRegs[FAST486_REG_EAX].Long,
+                                      sizeof(ULONG));
+        }
+        else
+        {
+            return Fast486WriteMemory(State,
+                                      (State->PrefixFlags & FAST486_PREFIX_SEG) ?
+                                      State->SegmentOverride : FAST486_REG_DS,
+                                      Offset,
+                                      &State->GeneralRegs[FAST486_REG_EAX].LowWord,
+                                      sizeof(USHORT));
+        }
     }
 }