X86: Implement cmps (string compare)

--HG--
extra : convert_revision : 0d6b783b2246b8ad8d91e4c63e407307ee11c651
This commit is contained in:
Gabe Black 2007-08-26 20:36:46 -07:00
parent 00d9036c62
commit 506bf83595
2 changed files with 59 additions and 15 deletions

View file

@ -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);

View file

@ -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"
};
'''