diff options
Diffstat (limited to 'src/arch/x86')
-rw-r--r-- | src/arch/x86/isa/decoder/one_byte_opcodes.isa | 4 | ||||
-rw-r--r-- | src/arch/x86/isa/insts/string/compare_strings.py | 70 |
2 files changed, 59 insertions, 15 deletions
diff --git a/src/arch/x86/isa/decoder/one_byte_opcodes.isa b/src/arch/x86/isa/decoder/one_byte_opcodes.isa index ee7fbc683..d8db47063 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: movs_Yb_Xb(); 0x5: movs_Yv_Xv(); - 0x6: cmps_Yb_Xb(); - 0x7: cmps_Yv_Xv(); + 0x6: StringInst::CMPS(Yb,Xb); + 0x7: StringInst::CMPS(Yv,Xv); } 0x15: decode OPCODE_OP_BOTTOM3 { 0x0: Inst::TEST(rAb,Ib); diff --git a/src/arch/x86/isa/insts/string/compare_strings.py b/src/arch/x86/isa/insts/string/compare_strings.py index 1484c4706..71b8511b4 100644 --- a/src/arch/x86/isa/insts/string/compare_strings.py +++ b/src/arch/x86/isa/insts/string/compare_strings.py @@ -53,16 +53,60 @@ # # Authors: Gabe Black -microcode = "" -#let {{ -# class CMPS(Inst): -# "GenFault ${new UnimpInstFault}" -# class CMPSB(Inst): -# "GenFault ${new UnimpInstFault}" -# class CMPSW(Inst): -# "GenFault ${new UnimpInstFault}" -# class CMPSD(Inst): -# "GenFault ${new UnimpInstFault}" -# class CMPSQ(Inst): -# "GenFault ${new UnimpInstFault}" -#}}; +microcode = ''' +def macroop CMPS_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 + + ld t1, seg, [1, t0, rsi] + ld t2, es, [1, t0, rdi] + sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF) + + add rdi, rdi, t3, dataSize=asz + add rsi, rsi, t3, dataSize=asz +}; + +# +# Versions which have the rep prefix. These could benefit from some loop +# unrolling. +# + +def macroop CMPS_E_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 + + ld t1, seg, [1, t0, rsi] + ld t2, es, [1, t0, rdi] + sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF) + + subi rcx, rcx, 1, flags=(EZF,), dataSize=asz + add rdi, rdi, t3, dataSize=asz + add rsi, rsi, t3, dataSize=asz + bri t0, 4, flags=(CSTRZnEZF,) + fault "NoFault" +}; + +def macroop CMPS_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 + + ld t1, seg, [1, t0, rsi] + ld t2, es, [1, t0, rdi] + sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF) + + subi rcx, rcx, 1, flags=(EZF,), dataSize=asz + add rdi, rdi, t3, dataSize=asz + add rsi, rsi, t3, dataSize=asz + bri t0, 4, flags=(CSTRnZnEZF,) + fault "NoFault" +}; +''' |