diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-17 19:49:59 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-18 00:25:02 +0200 |
commit | 28b6ba56aa5115efc127068fbf5839f06149c5e7 (patch) | |
tree | 6e01bf48f95c544f2f13d7cb6ae8057ed40e60bf /DevTools | |
parent | af7a1eca0bc79ade334dc2a30a035b7dffa5ce5a (diff) | |
download | serenity-28b6ba56aa5115efc127068fbf5839f06149c5e7.zip |
UserspaceEmulator: Add the LOOP/LOOPZ/LOOPNZ instructions
Diffstat (limited to 'DevTools')
-rw-r--r-- | DevTools/UserspaceEmulator/SoftCPU.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/DevTools/UserspaceEmulator/SoftCPU.cpp b/DevTools/UserspaceEmulator/SoftCPU.cpp index 3cccacdc21..270dbb7c66 100644 --- a/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -1356,9 +1356,45 @@ void SoftCPU::LMSW_RM16(const X86::Instruction&) { TODO(); } void SoftCPU::LODSB(const X86::Instruction&) { TODO(); } void SoftCPU::LODSD(const X86::Instruction&) { TODO(); } void SoftCPU::LODSW(const X86::Instruction&) { TODO(); } -void SoftCPU::LOOPNZ_imm8(const X86::Instruction&) { TODO(); } -void SoftCPU::LOOPZ_imm8(const X86::Instruction&) { TODO(); } -void SoftCPU::LOOP_imm8(const X86::Instruction&) { TODO(); } + +void SoftCPU::LOOPNZ_imm8(const X86::Instruction& insn) +{ + if (insn.a32()) { + set_ecx(ecx() - 1); + if (ecx() != 0 && !zf()) + set_eip(eip() + (i8)insn.imm8()); + } else { + set_cx(cx() - 1); + if (cx() != 0 && !zf()) + set_eip(eip() + (i8)insn.imm8()); + } +} +void SoftCPU::LOOPZ_imm8(const X86::Instruction& insn) +{ + if (insn.a32()) { + set_ecx(ecx() - 1); + if (ecx() != 0 && zf()) + set_eip(eip() + (i8)insn.imm8()); + } else { + set_cx(cx() - 1); + if (cx() != 0 && zf()) + set_eip(eip() + (i8)insn.imm8()); + } +} + +void SoftCPU::LOOP_imm8(const X86::Instruction& insn) +{ + if (insn.a32()) { + set_ecx(ecx() - 1); + if (ecx() != 0) + set_eip(eip() + (i8)insn.imm8()); + } else { + set_cx(cx() - 1); + if (cx() != 0) + set_eip(eip() + (i8)insn.imm8()); + } +} + void SoftCPU::LSL_reg16_RM16(const X86::Instruction&) { TODO(); } void SoftCPU::LSL_reg32_RM32(const X86::Instruction&) { TODO(); } void SoftCPU::LSS_reg16_mem16(const X86::Instruction&) { TODO(); } |