about summary refs log tree commit diff stats
path: root/src/emu
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-04-28 12:32:17 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-04-28 12:32:26 +0200
commit2ebde976db3337a0b78e1df0dd475c7bd5355511 (patch)
tree5076d16f5b20e04076e23dba02f362bbc087a927 /src/emu
parentdbaee7c49ca20c9af0c0f3cabfe1ed1d72021610 (diff)
downloadbox64-2ebde976db3337a0b78e1df0dd475c7bd5355511.tar.gz
box64-2ebde976db3337a0b78e1df0dd475c7bd5355511.zip
Improved x87 FIST(T)(P) opcode ([ARM64_DYNAREC] too)
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/x64rundd.c9
-rw-r--r--src/emu/x64rundf.c2
2 files changed, 9 insertions, 2 deletions
diff --git a/src/emu/x64rundd.c b/src/emu/x64rundd.c
index f33450a7..fc65f01d 100644
--- a/src/emu/x64rundd.c
+++ b/src/emu/x64rundd.c
@@ -125,7 +125,14 @@ uintptr_t RunDD(x64emu_t *emu, rex_t rex, uintptr_t addr)
                 break;

             case 1: /* FISTTP ED qword */

                 GETE8(0);

-                *(int64_t*)ED = ST0.d;

+                if(STll(0).sref==ST(0).sq)

+                    ED->sq[0] = STll(0).sq;

+                else {

+                    if(isgreater(ST0.d, (double)0x7fffffffffffffffLL) || isless(ST0.d, -(double)0x8000000000000000LL) || !isfinite(ST0.d))

+                        *(uint64_t*)ED = 0x8000000000000000LL;

+                    else

+                        *(int64_t*)ED = ST0.d;

+                }

                 fpu_do_pop(emu);

                 break;

             case 2: /* FST double */

diff --git a/src/emu/x64rundf.c b/src/emu/x64rundf.c
index 528a6c3f..d707863c 100644
--- a/src/emu/x64rundf.c
+++ b/src/emu/x64rundf.c
@@ -175,7 +175,7 @@ uintptr_t RunDF(x64emu_t *emu, rex_t rex, uintptr_t addr)
             if(STll(0).sref==ST(0).sq)

                 ED->sq[0] = STll(0).sq;

             else {

-                if(isgreater(ST0.d, (double)(int64_t)0x7fffffffffffffffLL) || isless(ST0.d, (double)(int64_t)0x8000000000000000LL) || !isfinite(ST0.d))

+                if(isgreater(ST0.d, (double)0x7fffffffffffffffLL) || isless(ST0.d, -(double)0x8000000000000000LL) || !isfinite(ST0.d))

                     ED->sq[0] = 0x8000000000000000LL;

                 else

                     ED->sq[0] = fpu_round(emu, ST0.d);