From 0ce6936e7d5373593f5a468529d30035db62b601 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 3 Apr 2007 14:56:24 +0000 Subject: [PATCH] Zero out ModRM if the byte isn't there, and fix some displacement size stuff. --HG-- extra : convert_revision : f43abf33a223a665b30098c63011fb162200d5e6 --- src/arch/x86/predecoder.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/arch/x86/predecoder.cc b/src/arch/x86/predecoder.cc index fbed4fe41..80971e7cf 100644 --- a/src/arch/x86/predecoder.cc +++ b/src/arch/x86/predecoder.cc @@ -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; } -- 2.30.2