From d759175767d28f820095168a5d87b2cec5ef0dc7 Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Fri, 23 Jul 2021 13:42:35 +0200 Subject: [PATCH] UserspaceEmulator: Stop overriding flags in FCOMI We no longer override the flags we just set. We now also unset of, af, and sf after the comparison. This fixes the asin function for LibM! --- Userland/DevTools/UserspaceEmulator/SoftFPU.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp index 06c283105e..568fda1616 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp @@ -888,15 +888,17 @@ void SoftFPU::FCOMI(const X86::Instruction& insn) m_cpu.set_zf(1); m_cpu.set_pf(1); m_cpu.set_cf(1); + } else { + m_cpu.set_zf(fpu_get(0) == fpu_get(i)); + m_cpu.set_pf(false); + m_cpu.set_cf(fpu_get(0) < fpu_get(i)); } if (!fpu_is_set(1)) fpu_set_exception(FPU_Exception::Underflow); - m_cpu.set_zf(fpu_get(0) == fpu_get(i)); - m_cpu.set_pf(false); - m_cpu.set_cf(fpu_get(0) < fpu_get(i)); - // FIXME: is this supposed to be here? - // m_cpu.set_of(false); + m_cpu.set_of(false); + m_cpu.set_af(false); + m_cpu.set_sf(false); // FIXME: Taint should be based on ST(0) and ST(i) m_cpu.m_flags_tainted = false; @@ -921,8 +923,10 @@ void SoftFPU::FUCOMI(const X86::Instruction& insn) m_cpu.set_zf(fpu_get(0) == fpu_get(i)); m_cpu.set_pf(false); m_cpu.set_cf(fpu_get(0) < fpu_get(i)); - m_cpu.set_of(false); } + m_cpu.set_of(false); + m_cpu.set_af(false); + m_cpu.set_sf(false); // FIXME: Taint should be based on ST(0) and ST(i) m_cpu.m_flags_tainted = false;