diff options
author | Hendiadyoin1 <leon2002.la@gmail.com> | 2021-07-23 00:41:34 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-11-07 22:42:23 +0000 |
commit | fa02b46295e1826201d47cef9d1ae8343d73e5c1 (patch) | |
tree | 3e92f2638b2d96754a70819fc003293e9178e09e | |
parent | 7214b08f813367133696d1052da9d791fad6b3c3 (diff) | |
download | serenity-fa02b46295e1826201d47cef9d1ae8343d73e5c1.zip |
UserspaceEmulator: Always set C1 when rounding
-rw-r--r-- | Userland/DevTools/UserspaceEmulator/SoftFPU.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp index 54cbf02d09..c22c03d357 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp @@ -197,13 +197,12 @@ template<Arithmetic T> ALWAYS_INLINE T SoftFPU::fpu_round_checked(long double value) { T result = fpu_round<T>(value); - if (auto rnd = value - result) { - if (rnd > 0) - set_c1(1); - else - set_c1(0); + if (result != value) fpu_set_exception(FPU_Exception::Precision); - } + if (result > value) + set_c1(1); + else + set_c1(0); return result; } @@ -791,13 +790,7 @@ void SoftFPU::FCHS(const X86::Instruction&) void SoftFPU::FRNDINT(const X86::Instruction&) { - auto res = fpu_round<long double>(fpu_get(0)); - if (auto rnd = (res - fpu_get(0))) { - if (rnd > 0) - set_c1(1); - else - set_c1(0); - } + auto res = fpu_round_checked<long double>(fpu_get(0)); fpu_set(0, res); } |