From 0bf457f715c35e027b78bef2b28b39e5c9dd73a7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 9 Mar 2021 14:30:30 +0100 Subject: [PATCH] UserspaceEmulator: Add partial support for some more x87 instructions Patch by @bcoles --- .../DevTools/UserspaceEmulator/SoftCPU.cpp | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp index e5d3063351..46ccd4c249 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -1582,11 +1582,23 @@ void SoftCPU::FLD1(const X86::Instruction&) fpu_push(1.0); } -void SoftCPU::FLDL2T(const X86::Instruction&) { TODO_INSN(); } +void SoftCPU::FLDL2T(const X86::Instruction&) +{ + fpu_push(log2f(10.0f)); +} + void SoftCPU::FLDL2E(const X86::Instruction&) { TODO_INSN(); } void SoftCPU::FLDPI(const X86::Instruction&) { TODO_INSN(); } -void SoftCPU::FLDLG2(const X86::Instruction&) { TODO_INSN(); } -void SoftCPU::FLDLN2(const X86::Instruction&) { TODO_INSN(); } + +void SoftCPU::FLDLG2(const X86::Instruction&) +{ + fpu_push(log10f(2.0f)); +} + +void SoftCPU::FLDLN2(const X86::Instruction&) +{ + fpu_push(logf(2.0f)); +} void SoftCPU::FLDZ(const X86::Instruction&) { @@ -1617,7 +1629,13 @@ void SoftCPU::FSQRT(const X86::Instruction&) } void SoftCPU::FSINCOS(const X86::Instruction&) { TODO_INSN(); } -void SoftCPU::FRNDINT(const X86::Instruction&) { TODO_INSN(); } + +void SoftCPU::FRNDINT(const X86::Instruction&) +{ + // FIXME: support rounding mode + fpu_set(0, round(fpu_get(0))); +} + void SoftCPU::FSCALE(const X86::Instruction&) { TODO_INSN(); } void SoftCPU::FSIN(const X86::Instruction&) @@ -1625,7 +1643,10 @@ void SoftCPU::FSIN(const X86::Instruction&) fpu_set(0, sin(fpu_get(0))); } -void SoftCPU::FCOS(const X86::Instruction&) { TODO_INSN(); } +void SoftCPU::FCOS(const X86::Instruction&) +{ + fpu_set(0, cos(fpu_get(0))); +} void SoftCPU::FIADD_RM32(const X86::Instruction& insn) {