diff options
| author | Hagb (Junyu Guo 郭俊余) <hagb_green@qq.com> | 2025-01-08 22:34:15 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-08 15:34:15 +0100 |
| commit | 653a67c8addcb980ce10a27765e582c972f8d69c (patch) | |
| tree | 98ac1036f34b2810a1f41a6126827445f7774fd4 /src/emu/x64runde.c | |
| parent | b99893d1c3506524103eebc2e4497a8be14cd6d0 (diff) | |
| download | box64-653a67c8addcb980ce10a27765e582c972f8d69c.tar.gz box64-653a67c8addcb980ce10a27765e582c972f8d69c.zip | |
Port rounding of some x87 instructions from Box86 (#2242)
* Port rounding of some x87 instructions from Box86 Ported from https://github.com/ptitSeb/box86/pull/951. The original pull request and this commit also contain some improvements on precision of `F2XM1` and `FYL2XP1`. * Run fpu_rounding test with dynarec only for ARM64 They have been implemented on dynarec only for ARM64.
Diffstat (limited to 'src/emu/x64runde.c')
| -rw-r--r-- | src/emu/x64runde.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/emu/x64runde.c b/src/emu/x64runde.c index 4cb5e4a2..8b082aa5 100644 --- a/src/emu/x64runde.c +++ b/src/emu/x64runde.c @@ -1,4 +1,5 @@ #define _GNU_SOURCE +#include <fenv.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -17,6 +18,7 @@ #include "x64primop.h" #include "x64trace.h" #include "x87emu_private.h" +#include "x87emu_setround.h" #include "box64context.h" #include "bridge.h" @@ -34,6 +36,7 @@ uintptr_t RunDE(x64emu_t *emu, rex_t rex, uintptr_t addr) x64emu_t*emu = test->emu; #endif + int oldround = fpu_setround(emu); nextop = F8; if(MODREG) switch(nextop) { @@ -126,6 +129,7 @@ uintptr_t RunDE(x64emu_t *emu, rex_t rex, uintptr_t addr) break; default: + fesetround(oldround); return 0; } else switch((nextop>>3)&7) { @@ -154,7 +158,9 @@ uintptr_t RunDE(x64emu_t *emu, rex_t rex, uintptr_t addr) ST0.d = (double)EW->sword[0] / ST0.d; break; default: + fesetround(oldround); return 0; } - return addr; + fesetround(oldround); + return addr; } \ No newline at end of file |