mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
UserspaceEmulator: Implement the CMPXCHG instruction
This commit is contained in:
parent
6ec0a63af1
commit
ed57efff4f
1 changed files with 37 additions and 3 deletions
|
@ -735,9 +735,43 @@ void SoftCPU::CMOVcc_reg32_RM32(const X86::Instruction& insn)
|
|||
void SoftCPU::CMPSB(const X86::Instruction&) { TODO(); }
|
||||
void SoftCPU::CMPSD(const X86::Instruction&) { TODO(); }
|
||||
void SoftCPU::CMPSW(const X86::Instruction&) { TODO(); }
|
||||
void SoftCPU::CMPXCHG_RM16_reg16(const X86::Instruction&) { TODO(); }
|
||||
void SoftCPU::CMPXCHG_RM32_reg32(const X86::Instruction&) { TODO(); }
|
||||
void SoftCPU::CMPXCHG_RM8_reg8(const X86::Instruction&) { TODO(); }
|
||||
|
||||
void SoftCPU::CMPXCHG_RM16_reg16(const X86::Instruction& insn)
|
||||
{
|
||||
auto current = insn.modrm().read16(*this, insn);
|
||||
if (current == eax()) {
|
||||
set_zf(true);
|
||||
insn.modrm().write16(*this, insn, gpr16(insn.reg16()));
|
||||
} else {
|
||||
set_zf(false);
|
||||
set_eax(current);
|
||||
}
|
||||
}
|
||||
|
||||
void SoftCPU::CMPXCHG_RM32_reg32(const X86::Instruction& insn)
|
||||
{
|
||||
auto current = insn.modrm().read32(*this, insn);
|
||||
if (current == eax()) {
|
||||
set_zf(true);
|
||||
insn.modrm().write32(*this, insn, gpr32(insn.reg32()));
|
||||
} else {
|
||||
set_zf(false);
|
||||
set_eax(current);
|
||||
}
|
||||
}
|
||||
|
||||
void SoftCPU::CMPXCHG_RM8_reg8(const X86::Instruction& insn)
|
||||
{
|
||||
auto current = insn.modrm().read8(*this, insn);
|
||||
if (current == eax()) {
|
||||
set_zf(true);
|
||||
insn.modrm().write8(*this, insn, gpr8(insn.reg8()));
|
||||
} else {
|
||||
set_zf(false);
|
||||
set_eax(current);
|
||||
}
|
||||
}
|
||||
|
||||
void SoftCPU::CPUID(const X86::Instruction&) { TODO(); }
|
||||
void SoftCPU::CWD(const X86::Instruction&) { TODO(); }
|
||||
void SoftCPU::CWDE(const X86::Instruction&) { TODO(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue