summaryrefslogtreecommitdiff
path: root/src/arch/x86/emulenv.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86/emulenv.cc')
-rw-r--r--src/arch/x86/emulenv.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/arch/x86/emulenv.cc b/src/arch/x86/emulenv.cc
index 28282dc7a..31b705d79 100644
--- a/src/arch/x86/emulenv.cc
+++ b/src/arch/x86/emulenv.cc
@@ -88,5 +88,18 @@ 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*/) {
+ seg = SEGMENT_REG_DS;
+ //Handle any segment override that might have been in the instruction
+ int segFromInst = machInst.legacy.seg;
+ if (segFromInst)
+ seg = (SegmentRegIndex)(segFromInst - 1);
+ } else {
+ seg = SEGMENT_REG_SS;
+ }
}