UserspaceEmulator: Implement DIV_RM32

Not using inline assembly for this one since flags are undefined after
a DIV instruction anyway.
This commit is contained in:
Andreas Kling 2020-07-12 14:53:19 +02:00
parent 062e2f8614
commit a424208399

View file

@ -804,7 +804,25 @@ void SoftCPU::DEC_reg32(const X86::Instruction& insn)
}
void SoftCPU::DIV_RM16(const X86::Instruction&) { TODO(); }
void SoftCPU::DIV_RM32(const X86::Instruction&) { TODO(); }
void SoftCPU::DIV_RM32(const X86::Instruction& insn)
{
auto divisor = insn.modrm().read32(*this, insn);
if (divisor == 0) {
warn() << "Divide by zero";
TODO();
}
u64 dividend = ((u64)edx() << 32) | eax();
auto result = dividend / divisor;
if (result > NumericLimits<u32>::max()) {
warn() << "Divide overflow";
TODO();
}
set_eax(result);
set_edx(dividend % divisor);
}
void SoftCPU::DIV_RM8(const X86::Instruction&) { TODO(); }
void SoftCPU::ENTER16(const X86::Instruction&) { TODO(); }
void SoftCPU::ENTER32(const X86::Instruction&) { TODO(); }