summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/x86/isa/decoder/one_byte_opcodes.isa8
-rw-r--r--src/arch/x86/isa/formats/string.isa28
-rw-r--r--src/arch/x86/isa/insts/general_purpose/string/move_string.py20
-rw-r--r--src/arch/x86/isa/insts/general_purpose/string/store_string.py18
4 files changed, 33 insertions, 41 deletions
diff --git a/src/arch/x86/isa/decoder/one_byte_opcodes.isa b/src/arch/x86/isa/decoder/one_byte_opcodes.isa
index 0816eb175..f76912f06 100644
--- a/src/arch/x86/isa/decoder/one_byte_opcodes.isa
+++ b/src/arch/x86/isa/decoder/one_byte_opcodes.isa
@@ -332,8 +332,8 @@
0x3: mov_Ov_rAX();
0x4: StringInst::MOVS(Yb,Xb);
0x5: StringInst::MOVS(Yv,Xv);
- 0x6: StringInst::CMPS(Yb,Xb);
- 0x7: StringInst::CMPS(Yv,Xv);
+ 0x6: StringTestInst::CMPS(Yb,Xb);
+ 0x7: StringTestInst::CMPS(Yv,Xv);
}
0x15: decode OPCODE_OP_BOTTOM3 {
0x0: Inst::TEST(rAb,Ib);
@@ -342,8 +342,8 @@
0x3: StringInst::STOS(Yv);
0x4: lods_Al_Xb();
0x5: lods_rAX_Xv();
- 0x6: StringInst::SCAS(Yb);
- 0x7: StringInst::SCAS(Yv);
+ 0x6: StringTestInst::SCAS(Yb);
+ 0x7: StringTestInst::SCAS(Yv);
}
format Inst {
0x16: MOV(Bb,Ib);
diff --git a/src/arch/x86/isa/formats/string.isa b/src/arch/x86/isa/formats/string.isa
index cd182ff62..b1d3c4bbe 100644
--- a/src/arch/x86/isa/formats/string.isa
+++ b/src/arch/x86/isa/formats/string.isa
@@ -61,7 +61,7 @@
//
//////////////////////////////////////////////////////////////////////////
-def format StringInst(*opTypeSet) {{
+def format StringTestInst(*opTypeSet) {{
allBlocks = OutputBlocks()
regBlocks = specializeInst(Name, list(opTypeSet), EmulEnv())
@@ -86,3 +86,29 @@ def format StringInst(*opTypeSet) {{
(header_output, decoder_output,
decode_block, exec_output) = allBlocks.makeList()
}};
+
+def format StringInst(*opTypeSet) {{
+ allBlocks = OutputBlocks()
+
+ regBlocks = specializeInst(Name, list(opTypeSet), EmulEnv())
+ eBlocks = specializeInst(Name + "_E", list(opTypeSet), EmulEnv())
+
+ for blocks in (regBlocks, eBlocks):
+ allBlocks.header_output += blocks.header_output
+ allBlocks.decoder_output += blocks.decoder_output
+ allBlocks.exec_output += blocks.exec_output
+
+ allBlocks.decode_block = '''
+ if (LEGACY_REP) {
+ %s
+ } else if (LEGACY_REPNE) {
+ // The repne prefix is illegal
+ return new MicroFault(machInst, "illprefix", new InvalidOpcode);
+ } else {
+ %s
+ }
+ ''' % (eBlocks.decode_block, regBlocks.decode_block)
+
+ (header_output, decoder_output,
+ decode_block, exec_output) = allBlocks.makeList()
+}};
diff --git a/src/arch/x86/isa/insts/general_purpose/string/move_string.py b/src/arch/x86/isa/insts/general_purpose/string/move_string.py
index 6a78a2cd4..b64acfdc2 100644
--- a/src/arch/x86/isa/insts/general_purpose/string/move_string.py
+++ b/src/arch/x86/isa/insts/general_purpose/string/move_string.py
@@ -82,25 +82,7 @@ topOfLoop:
subi rcx, rcx, 1, flags=(EZF,), dataSize=asz
add rdi, rdi, t3, dataSize=asz
add rsi, rsi, t3, dataSize=asz
- bri t0, label("topOfLoop"), flags=(CSTRZnEZF,)
- fault "NoFault"
-};
-
-def macroop MOVS_N_M_M {
- # Find the constant we need to either add or subtract from rdi
- ruflag t0, 10
- movi t3, t3, dsz, flags=(CEZF,), dataSize=asz
- subi t4, t0, dsz, dataSize=asz
- mov t3, t3, t4, flags=(nCEZF,), dataSize=asz
-
-topOfLoop:
- ld t1, seg, [1, t0, rsi]
- st t1, es, [1, t0, rdi]
-
- subi rcx, rcx, 1, flags=(EZF,), dataSize=asz
- add rdi, rdi, t3, dataSize=asz
- add rsi, rsi, t3, dataSize=asz
- bri t0, label("topOfLoop"), flags=(CSTRnZnEZF,)
+ bri t0, label("topOfLoop"), flags=(nCEZF,)
fault "NoFault"
};
'''
diff --git a/src/arch/x86/isa/insts/general_purpose/string/store_string.py b/src/arch/x86/isa/insts/general_purpose/string/store_string.py
index a8655cf96..a8d558929 100644
--- a/src/arch/x86/isa/insts/general_purpose/string/store_string.py
+++ b/src/arch/x86/isa/insts/general_purpose/string/store_string.py
@@ -78,23 +78,7 @@ topOfLoop:
subi rcx, rcx, 1, flags=(EZF,), dataSize=asz
add rdi, rdi, t3, dataSize=asz
- bri t0, label("topOfLoop"), flags=(CSTRZnEZF,)
- fault "NoFault"
-};
-
-def macroop STOS_N_M {
- # Find the constant we need to either add or subtract from rdi
- ruflag t0, 10
- movi t3, t3, dsz, flags=(CEZF,), dataSize=asz
- subi t4, t0, dsz, dataSize=asz
- mov t3, t3, t4, flags=(nCEZF,), dataSize=asz
-
-topOfLoop:
- st rax, es, [1, t0, rdi]
-
- subi rcx, rcx, 1, flags=(EZF,), dataSize=asz
- add rdi, rdi, t3, dataSize=asz
- bri t0, label("topOfLoop"), flags=(CSTRnZnEZF,)
+ bri t0, label("topOfLoop"), flags=(nCEZF,)
fault "NoFault"
};
'''