X86: Fix segment override prefixes on instructions that use rbp/rsp and a displacement.

This commit is contained in:
Gabe Black
2009-08-03 11:01:40 -07:00
parent 38c2af17a5
commit 676dc6d292
4 changed files with 13 additions and 5 deletions

View File

@@ -118,8 +118,7 @@ void EmulEnv::doModRM(const ExtMachInst & machInst)
//Figure out what segment to use. This won't be entirely accurate since
//the presence of a displacement is supposed to make the instruction
//default to the data segment.
if ((base != INTREG_RBP && base != INTREG_RSP) ||
0/*Has an immediate offset*/) {
if ((base != INTREG_RBP && base != INTREG_RSP) || machInst.dispSize) {
seg = SEGMENT_REG_DS;
//Handle any segment override that might have been in the instruction
int segFromInst = machInst.legacy.seg;

View File

@@ -77,6 +77,7 @@ namespace X86ISA
immediateCollected = 0;
emi.immediate = 0;
emi.displacement = 0;
emi.dispSize = 0;
emi.modRM = 0;
emi.sib = 0;
@@ -383,6 +384,8 @@ namespace X86ISA
emiIsReady = true;
nextState = ResetState;
}
emi.dispSize = displacementSize;
}
else
nextState = DisplacementState;

View File

@@ -175,6 +175,8 @@ namespace X86ISA
uint8_t addrSize;
//The effective stack size.
uint8_t stackSize;
//The size of the displacement
uint8_t dispSize;
//Mode information
OperatingMode mode;
@@ -187,12 +189,13 @@ namespace X86ISA
"op = {\n\t\tnum = %d,\n\t\top = %#x,\n\t\t"
"prefixA = %#x,\n\t\tprefixB = %#x\n\t},\n\t"
"modRM = %#x,\n\tsib = %#x,\n\t"
"immediate = %#x,\n\tdisplacement = %#x\n}\n",
"immediate = %#x,\n\tdisplacement = %#x\n\t"
"dispSize = %d}\n",
(uint8_t)emi.legacy, (uint8_t)emi.rex,
emi.opcode.num, (uint8_t)emi.opcode.op,
emi.opcode.prefixA, emi.opcode.prefixB,
(uint8_t)emi.modRM, (uint8_t)emi.sib,
emi.immediate, emi.displacement);
emi.immediate, emi.displacement, emi.dispSize);
return os;
}
@@ -227,6 +230,8 @@ namespace X86ISA
return false;
if(emi1.stackSize != emi2.stackSize)
return false;
if(emi1.dispSize != emi2.dispSize)
return false;
return true;
}

View File

@@ -82,7 +82,8 @@ namespace __hash_namespace {
((uint64_t)emi.opcode.op)) ^
emi.immediate ^ emi.displacement ^
emi.mode ^
emi.opSize ^ emi.addrSize ^ emi.stackSize;
emi.opSize ^ emi.addrSize ^
emi.stackSize ^ emi.dispSize;
};
};
}