mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +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
1 changed files with 19 additions and 1 deletions
|
@ -804,7 +804,25 @@ void SoftCPU::DEC_reg32(const X86::Instruction& insn)
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftCPU::DIV_RM16(const X86::Instruction&) { TODO(); }
|
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::DIV_RM8(const X86::Instruction&) { TODO(); }
|
||||||
void SoftCPU::ENTER16(const X86::Instruction&) { TODO(); }
|
void SoftCPU::ENTER16(const X86::Instruction&) { TODO(); }
|
||||||
void SoftCPU::ENTER32(const X86::Instruction&) { TODO(); }
|
void SoftCPU::ENTER32(const X86::Instruction&) { TODO(); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue