mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-09 01:20:46 +00:00
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:
parent
062e2f8614
commit
a424208399
|
@ -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(); }
|
||||
|
|
Loading…
Reference in a new issue