[FAST486]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Mon, 11 Nov 2013 17:24:22 +0000 (17:24 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Mon, 11 Nov 2013 17:24:22 +0000 (17:24 +0000)
Fix the Mod-Reg-R/M parser. EBP cannot be used as a SIB byte base,
instead it's used to mark that the base is an immediate operand.

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

lib/fast486/common.inl

index 38dadbf..524d3d9 100644 (file)
@@ -719,7 +719,21 @@ Fast486ParseModRegRm(PFAST486_STATE State,
             Index = (SibByte >> 3) & 0x07;
             if (Index != FAST486_REG_ESP) Index = State->GeneralRegs[Index].Long;
             else Index = 0;
             Index = (SibByte >> 3) & 0x07;
             if (Index != FAST486_REG_ESP) Index = State->GeneralRegs[Index].Long;
             else Index = 0;
-            Base = State->GeneralRegs[SibByte & 0x07].Long;
+
+            if ((SibByte & 0x07) != FAST486_REG_EBP)
+            {
+                /* Use the register a base */
+                Base = State->GeneralRegs[SibByte & 0x07].Long;
+            }
+            else
+            {
+                /* Fetch the base */
+                if (!Fast486FetchDword(State, &Base))
+                {
+                    /* Exception occurred */
+                    return FALSE;
+                }
+            }
 
             /* Calculate the address */
             ModRegRm->MemoryAddress = Base + Index * Scale;
 
             /* Calculate the address */
             ModRegRm->MemoryAddress = Base + Index * Scale;