Zero out ModRM if the byte isn't there, and fix some displacement size stuff.
authorGabe Black <gblack@eecs.umich.edu>
Tue, 3 Apr 2007 14:56:24 +0000 (14:56 +0000)
committerGabe Black <gblack@eecs.umich.edu>
Tue, 3 Apr 2007 14:56:24 +0000 (14:56 +0000)
--HG--
extra : convert_revision : f43abf33a223a665b30098c63011fb162200d5e6

src/arch/x86/predecoder.cc

index fbed4fe41d3ad1d06d64ff11d2d84e404d86817c..80971e7cfb8350a38015d8aff610be0f86564a84 100644 (file)
@@ -212,11 +212,16 @@ namespace X86ISA
             //Determine what to expect next
             if (UsesModRM[emi.opcode.num - 1][nextByte]) {
                 nextState = ModRMState;
-            } else if(immediateSize) {
-                nextState = ImmediateState;
             } else {
-                emiIsReady = true;
-                nextState = PrefixState;
+                //If there's no modRM byte, set it to 0 so we can detect
+                //that later.
+                emi.modRM = 0;
+                if(immediateSize) {
+                    nextState = ImmediateState;
+                } else {
+                    emiIsReady = true;
+                    nextState = PrefixState;
+                }
             }
         }
         return nextState;
@@ -241,11 +246,11 @@ namespace X86ISA
                 displacementSize = 0;
         } else {
             //figure out 32/64 bit displacement size
-            if(nextByte & 0xC7 == 0x05 ||
+            if(nextByte & 0xC6 == 0x04 ||
                     nextByte & 0xC0 == 0x80)
                 displacementSize = 4;
             else if(nextByte & 0xC0 == 0x40)
-                displacementSize = 2;
+                displacementSize = 1;
             else
                 displacementSize = 0;
         }