diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-12 14:45:46 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-12 14:45:46 +0200 |
commit | 062e2f861423828a3bbde9d4075d2e54a77f86eb (patch) | |
tree | 262c0605d2eec114b21b55a5c24d99c5bcc75300 | |
parent | 536ca0f8c91142a455bb42429813e1694df4eb3e (diff) | |
download | serenity-062e2f861423828a3bbde9d4075d2e54a77f86eb.zip |
UserspaceEmulator: Implement the XCHG instruction
-rw-r--r-- | DevTools/UserspaceEmulator/SoftCPU.cpp | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/DevTools/UserspaceEmulator/SoftCPU.cpp b/DevTools/UserspaceEmulator/SoftCPU.cpp index 523b41bf1b..0fe312b81c 100644 --- a/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -1573,11 +1573,42 @@ void SoftCPU::WBINVD(const X86::Instruction&) { TODO(); } void SoftCPU::XADD_RM16_reg16(const X86::Instruction&) { TODO(); } void SoftCPU::XADD_RM32_reg32(const X86::Instruction&) { TODO(); } void SoftCPU::XADD_RM8_reg8(const X86::Instruction&) { TODO(); } -void SoftCPU::XCHG_AX_reg16(const X86::Instruction&) { TODO(); } -void SoftCPU::XCHG_EAX_reg32(const X86::Instruction&) { TODO(); } -void SoftCPU::XCHG_reg16_RM16(const X86::Instruction&) { TODO(); } -void SoftCPU::XCHG_reg32_RM32(const X86::Instruction&) { TODO(); } -void SoftCPU::XCHG_reg8_RM8(const X86::Instruction&) { TODO(); } + +void SoftCPU::XCHG_AX_reg16(const X86::Instruction& insn) +{ + auto temp = gpr16(insn.reg16()); + gpr16(insn.reg16()) = eax(); + set_eax(temp); +} + +void SoftCPU::XCHG_EAX_reg32(const X86::Instruction& insn) +{ + auto temp = gpr32(insn.reg32()); + gpr32(insn.reg32()) = eax(); + set_eax(temp); +} + +void SoftCPU::XCHG_reg16_RM16(const X86::Instruction& insn) +{ + auto temp = insn.modrm().read16(*this, insn); + insn.modrm().write16(*this, insn, gpr16(insn.reg16())); + gpr16(insn.reg16()) = temp; +} + +void SoftCPU::XCHG_reg32_RM32(const X86::Instruction& insn) +{ + auto temp = insn.modrm().read32(*this, insn); + insn.modrm().write32(*this, insn, gpr32(insn.reg32())); + gpr32(insn.reg32()) = temp; +} + +void SoftCPU::XCHG_reg8_RM8(const X86::Instruction& insn) +{ + auto temp = insn.modrm().read8(*this, insn); + insn.modrm().write8(*this, insn, gpr8(insn.reg8())); + gpr8(insn.reg8()) = temp; +} + void SoftCPU::XLAT(const X86::Instruction&) { TODO(); } #define DEFINE_GENERIC_INSN_HANDLERS_PARTIAL(mnemonic, op, update_dest) \ |