X86: Implement the CMPXCHG8B/CMPXCHG16B instruction.
This commit is contained in:
parent
bbf117b20e
commit
c5fae51774
3 changed files with 98 additions and 2 deletions
|
@ -160,7 +160,8 @@
|
|||
0x1: XADD_LOCKED(Mv,Gv);
|
||||
//0x7: group9();
|
||||
0x7: decode MODRM_REG {
|
||||
0x1: WarnUnimpl::cmpxchg_Mq_LOCKED();
|
||||
//Also CMPXCHG16B
|
||||
0x1: CMPXCHG8B_LOCKED(Mdp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -898,7 +898,8 @@
|
|||
0x1: Inst::XADD(Ev,Gv);
|
||||
//0x7: group9();
|
||||
0x7: decode MODRM_REG {
|
||||
0x1: cmpxchg_Mq();
|
||||
//Also CMPXCHG16B
|
||||
0x1: Inst::CMPXCHG8B(Mdp);
|
||||
0x6: decode LEGACY_OP {
|
||||
0x1: vmclear_Mq();
|
||||
default: decode LEGACY_REP {
|
||||
|
|
|
@ -98,6 +98,100 @@ def macroop CMPXCHG_LOCKED_P_R {
|
|||
mov rax, rax, t1, flags=(nCZF,)
|
||||
};
|
||||
|
||||
def macroop CMPXCHG8B_M {
|
||||
lea t1, seg, sib, disp, dataSize=asz
|
||||
ldst t2, seg, [1, t0, t1], 0
|
||||
ldst t3, seg, [1, t0, t1], dsz
|
||||
|
||||
sub t0, rax, t2, flags=(ZF,)
|
||||
br label("doneComparing"), flags=(nCZF,)
|
||||
sub t0, rdx, t3, flags=(ZF,)
|
||||
doneComparing:
|
||||
|
||||
# If they're equal, set t3:t2 to rbx:rcx to write to memory
|
||||
mov t2, t2, rbx, flags=(CZF,)
|
||||
mov t3, t3, rcx, flags=(CZF,)
|
||||
|
||||
# If they're not equal, set rdx:rax to the value from memory.
|
||||
mov rax, rax, t2, flags=(nCZF,)
|
||||
mov rdx, rdx, t3, flags=(nCZF,)
|
||||
|
||||
# Write to memory
|
||||
st t3, seg, [1, t0, t1], dsz
|
||||
st t2, seg, [1, t0, t1], 0
|
||||
};
|
||||
|
||||
def macroop CMPXCHG8B_P {
|
||||
rdip t7
|
||||
lea t1, seg, riprel, disp, dataSize=asz
|
||||
ldst t2, seg, [1, t0, t1], 0
|
||||
ldst t3, seg, [1, t0, t1], dsz
|
||||
|
||||
sub t0, rax, t2, flags=(ZF,)
|
||||
br label("doneComparing"), flags=(nCZF,)
|
||||
sub t0, rdx, t3, flags=(ZF,)
|
||||
doneComparing:
|
||||
|
||||
# If they're equal, set t3:t2 to rbx:rcx to write to memory
|
||||
mov t2, t2, rbx, flags=(CZF,)
|
||||
mov t3, t3, rcx, flags=(CZF,)
|
||||
|
||||
# If they're not equal, set rdx:rax to the value from memory.
|
||||
mov rax, rax, t2, flags=(nCZF,)
|
||||
mov rdx, rdx, t3, flags=(nCZF,)
|
||||
|
||||
# Write to memory
|
||||
st t3, seg, [1, t0, t1], dsz
|
||||
st t2, seg, [1, t0, t1], 0
|
||||
};
|
||||
|
||||
def macroop CMPXCHG8B_LOCKED_M {
|
||||
lea t1, seg, sib, disp, dataSize=asz
|
||||
ldstl t2, seg, [1, t0, t1], 0
|
||||
ldstl t3, seg, [1, t0, t1], dsz
|
||||
|
||||
sub t0, rax, t2, flags=(ZF,)
|
||||
br label("doneComparing"), flags=(nCZF,)
|
||||
sub t0, rdx, t3, flags=(ZF,)
|
||||
doneComparing:
|
||||
|
||||
# If they're equal, set t3:t2 to rbx:rcx to write to memory
|
||||
mov t2, t2, rbx, flags=(CZF,)
|
||||
mov t3, t3, rcx, flags=(CZF,)
|
||||
|
||||
# If they're not equal, set rdx:rax to the value from memory.
|
||||
mov rax, rax, t2, flags=(nCZF,)
|
||||
mov rdx, rdx, t3, flags=(nCZF,)
|
||||
|
||||
# Write to memory
|
||||
stul t3, seg, [1, t0, t1], dsz
|
||||
stul t2, seg, [1, t0, t1], 0
|
||||
};
|
||||
|
||||
def macroop CMPXCHG8B_LOCKED_P {
|
||||
rdip t7
|
||||
lea t1, seg, riprel, disp, dataSize=asz
|
||||
ldstl t2, seg, [1, t0, t1], 0
|
||||
ldstl t3, seg, [1, t0, t1], dsz
|
||||
|
||||
sub t0, rax, t2, flags=(ZF,)
|
||||
br label("doneComparing"), flags=(nCZF,)
|
||||
sub t0, rdx, t3, flags=(ZF,)
|
||||
doneComparing:
|
||||
|
||||
# If they're equal, set t3:t2 to rbx:rcx to write to memory
|
||||
mov t2, t2, rbx, flags=(CZF,)
|
||||
mov t3, t3, rcx, flags=(CZF,)
|
||||
|
||||
# If they're not equal, set rdx:rax to the value from memory.
|
||||
mov rax, rax, t2, flags=(nCZF,)
|
||||
mov rdx, rdx, t3, flags=(nCZF,)
|
||||
|
||||
# Write to memory
|
||||
stul t3, seg, [1, t0, t1], dsz
|
||||
stul t2, seg, [1, t0, t1], 0
|
||||
};
|
||||
|
||||
def macroop XADD_M_R {
|
||||
ldst t1, seg, sib, disp
|
||||
add t2, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
|
||||
|
|
Loading…
Reference in a new issue