summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2009-02-27 09:23:58 -0800
committerGabe Black <gblack@eecs.umich.edu>2009-02-27 09:23:58 -0800
commit3dfa564e70e4804ef118ba94c81233fb85f56ba2 (patch)
tree0423a50010c4f19c3871c67eb72eb5c186d93e70 /src
parent9dfa3f7f735ead0ada9eb79227f217d0d76e0f49 (diff)
downloadgem5-3dfa564e70e4804ef118ba94c81233fb85f56ba2.tar.xz
X86: Respect segment override prefixes even when there's no ModRM byte.
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86/emulenv.cc8
-rw-r--r--src/arch/x86/emulenv.hh1
-rw-r--r--src/arch/x86/isa/macroop.isa11
3 files changed, 16 insertions, 4 deletions
diff --git a/src/arch/x86/emulenv.cc b/src/arch/x86/emulenv.cc
index 30ed80942..0d7b32130 100644
--- a/src/arch/x86/emulenv.cc
+++ b/src/arch/x86/emulenv.cc
@@ -105,3 +105,11 @@ void EmulEnv::doModRM(const ExtMachInst & machInst)
}
}
+void EmulEnv::setSeg(const ExtMachInst & machInst)
+{
+ 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);
+}
diff --git a/src/arch/x86/emulenv.hh b/src/arch/x86/emulenv.hh
index 1044dbdf9..cdb1bf863 100644
--- a/src/arch/x86/emulenv.hh
+++ b/src/arch/x86/emulenv.hh
@@ -86,6 +86,7 @@ namespace X86ISA
{;}
void doModRM(const ExtMachInst & machInst);
+ void setSeg(const ExtMachInst & machInst);
};
};
diff --git a/src/arch/x86/isa/macroop.isa b/src/arch/x86/isa/macroop.isa
index 8eaf5f786..3a836ff68 100644
--- a/src/arch/x86/isa/macroop.isa
+++ b/src/arch/x86/isa/macroop.isa
@@ -135,7 +135,7 @@ def template MacroConstructor {{
%(adjust_env)s;
%(adjust_imm)s;
%(adjust_disp)s;
- %(do_modrm)s;
+ %(init_env)s;
%(constructor)s;
const char *macrocodeBlock = "%(class_name)s";
//alloc_microops is the code that sets up the microops
@@ -166,7 +166,7 @@ let {{
}
self.declared = False
self.adjust_env = ""
- self.doModRM = ""
+ self.init_env = ""
self.adjust_imm = '''
uint64_t adjustedImm = IMMEDIATE;
//This is to pacify gcc in case the immediate isn't used.
@@ -228,7 +228,7 @@ let {{
"adjust_disp" : self.adjust_disp,
"disassembly" : env.disassembly,
"regSize" : regSize,
- "do_modrm" : self.doModRM})
+ "init_env" : self.initEnv})
return MacroConstructor.subst(iop) + \
MacroDisassembly.subst(iop);
}};
@@ -304,6 +304,7 @@ let {{
let {{
doModRMString = "env.doModRM(machInst);\n"
+ noModRMString = "env.setSeg(machInst);\n"
def genMacroop(Name, env):
blocks = OutputBlocks()
if not macroopDict.has_key(Name):
@@ -311,7 +312,9 @@ let {{
macroop = macroopDict[Name]
if not macroop.declared:
if env.doModRM:
- macroop.doModRM = doModRMString
+ macroop.initEnv = doModRMString
+ else:
+ macroop.initEnv = noModRMString
blocks.header_output = macroop.getDeclaration()
blocks.decoder_output = macroop.getDefinition(env)
macroop.declared = True