1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibX86: Use names closer to the spec for the Modrm

This gets rid of a lot of magic number shifts and ands.
This commit is contained in:
Hendiadyoin1 2021-07-08 17:46:13 +02:00 committed by Andreas Kling
parent 68193c365f
commit efa42c4d45
3 changed files with 58 additions and 53 deletions

View file

@ -1721,7 +1721,7 @@ void SoftCPU::FCMOVB(const X86::Instruction& insn)
{
VERIFY(insn.modrm().is_register());
if (cf())
fpu_set(0, fpu_get(insn.rm() & 7));
fpu_set(0, fpu_get(insn.modrm().rm()));
}
void SoftCPU::FIMUL_RM32(const X86::Instruction& insn)
@ -1736,7 +1736,7 @@ void SoftCPU::FCMOVE(const X86::Instruction& insn)
{
VERIFY(insn.modrm().is_register());
if (zf())
fpu_set(0, fpu_get(insn.rm() & 7));
fpu_set(0, fpu_get(insn.modrm().rm()));
}
void SoftCPU::FICOM_RM32(const X86::Instruction&) { TODO_INSN(); }
@ -1744,7 +1744,7 @@ void SoftCPU::FICOM_RM32(const X86::Instruction&) { TODO_INSN(); }
void SoftCPU::FCMOVBE(const X86::Instruction& insn)
{
if (evaluate_condition(6))
fpu_set(0, fpu_get(insn.rm() & 7));
fpu_set(0, fpu_get(insn.modrm().rm()));
}
void SoftCPU::FICOMP_RM32(const X86::Instruction&) { TODO_INSN(); }
@ -1832,7 +1832,7 @@ void SoftCPU::FIST_RM32(const X86::Instruction& insn)
void SoftCPU::FCMOVNBE(const X86::Instruction& insn)
{
if (evaluate_condition(7))
fpu_set(0, fpu_get(insn.rm() & 7));
fpu_set(0, fpu_get(insn.modrm().rm()));
}
void SoftCPU::FISTP_RM32(const X86::Instruction& insn)
@ -1869,7 +1869,7 @@ void SoftCPU::FLD_RM80(const X86::Instruction& insn)
void SoftCPU::FUCOMI(const X86::Instruction& insn)
{
auto i = insn.rm() & 7;
auto i = insn.modrm().rm();
// FIXME: Unordered comparison checks.
// FIXME: QNaN / exception handling.
// FIXME: Set C0, C2, C3 in FPU status word.
@ -1890,7 +1890,7 @@ void SoftCPU::FUCOMI(const X86::Instruction& insn)
void SoftCPU::FCOMI(const X86::Instruction& insn)
{
auto i = insn.rm() & 7;
auto i = insn.modrm().rm();
// FIXME: QNaN / exception handling.
// FIXME: Set C0, C2, C3 in FPU status word.
set_zf(fpu_get(0) == fpu_get(i));