diff --git a/DevTools/UserspaceEmulator/SoftCPU.cpp b/DevTools/UserspaceEmulator/SoftCPU.cpp index d65dcad0e6..207c878489 100644 --- a/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -1369,9 +1369,32 @@ void SoftCPU::LGS_reg32_mem32(const X86::Instruction&) { TODO(); } void SoftCPU::LIDT(const X86::Instruction&) { TODO(); } void SoftCPU::LLDT_RM16(const X86::Instruction&) { TODO(); } 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(); } + +template +ALWAYS_INLINE static void do_lods(SoftCPU& cpu, const X86::Instruction& insn) +{ + auto src_segment = cpu.segment(insn.segment_prefix().value_or(X86::SegmentRegister::DS)); + cpu.do_once_or_repeat(insn, [&] { + auto src = cpu.read_memory({ src_segment, cpu.source_index(insn.a32()) }); + cpu.gpr(X86::RegisterAL) = src; + cpu.step_source_index(insn.a32(), sizeof(T)); + }); +} + +void SoftCPU::LODSB(const X86::Instruction& insn) +{ + do_lods(*this, insn); +} + +void SoftCPU::LODSD(const X86::Instruction& insn) +{ + do_lods(*this, insn); +} + +void SoftCPU::LODSW(const X86::Instruction& insn) +{ + do_lods(*this, insn); +} void SoftCPU::LOOPNZ_imm8(const X86::Instruction& insn) {