about summary refs log tree commit diff stats
path: root/src/emu
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-04-16 08:59:28 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-04-16 08:59:28 +0200
commit3faf66a36bd02eea7d1e6e338f8de4151a3593fd (patch)
tree29ca2dfacbaa7c92781fd00545241d8b1a1bbe4d /src/emu
parentd94b47d1b0c76929324dde744f0b8e3ad02ca374 (diff)
downloadbox64-3faf66a36bd02eea7d1e6e338f8de4151a3593fd.tar.gz
box64-3faf66a36bd02eea7d1e6e338f8de4151a3593fd.zip
Some more NAN bordercase handling ([DYNAREC] too, but made FASTNAN default)
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/x64run660f.c22
-rw-r--r--src/emu/x64runf20f.c12
2 files changed, 30 insertions, 4 deletions
diff --git a/src/emu/x64run660f.c b/src/emu/x64run660f.c
index 5fe52958..ac255a0f 100644
--- a/src/emu/x64run660f.c
+++ b/src/emu/x64run660f.c
@@ -847,8 +847,15 @@ int Run660F(x64emu_t *emu, rex_t rex)
         nextop = F8;

         GETEX(0);

         GETGX;

-        GX->d[0] += EX->d[0];

-        GX->d[1] += EX->d[1];

+        for(int i=0; i<2; ++i) {

+            #ifndef NOALIGN

+                // add generate a -NAN only if doing inf + -inf

+                if((isinf(GX->d[i]) && isinf(EX->d[i]) && (EX->q[i]&0x8000000000000000LL)!=(GX->q[i]&0x8000000000000000LL)))

+                    GX->d[i] = -NAN;

+                else

+            #endif

+            GX->d[i] += EX->d[i];

+        }

         break;

     case 0x59:                      /* MULPD Gx, Ex */

         nextop = F8;

@@ -907,8 +914,15 @@ int Run660F(x64emu_t *emu, rex_t rex)
         nextop = F8;

         GETEX(0);

         GETGX;

-        GX->d[0] -= EX->d[0];

-        GX->d[1] -= EX->d[1];

+        for(int i=0; i<2; ++i) {

+            #ifndef NOALIGN

+                // sub generate a -NAN only if doing inf - inf

+                if((isinf(GX->d[i]) && isinf(EX->d[i]) && (EX->q[i]&0x8000000000000000LL)==(GX->q[i]&0x8000000000000000LL)))

+                    GX->d[i] = -NAN;

+                else

+            #endif

+            GX->d[i] -= EX->d[i];

+        }

         break;

     case 0x5D:                      /* MINPD Gx, Ex */

         nextop = F8;

diff --git a/src/emu/x64runf20f.c b/src/emu/x64runf20f.c
index 3ecf43ef..aebf434d 100644
--- a/src/emu/x64runf20f.c
+++ b/src/emu/x64runf20f.c
@@ -137,6 +137,12 @@ int RunF20F(x64emu_t *emu, rex_t rex)
         nextop = F8;

         GETEX(0);

         GETGX;

+        #ifndef NOALIGN

+        // add generate a -NAN only if doing inf + -inf

+        if((isinf(GX->d[0]) && isinf(EX->d[0]) && (EX->q[0]&0x8000000000000000LL)!=(GX->q[0]&0x8000000000000000LL)))

+            GX->d[0] = -NAN;

+        else

+        #endif

         GX->d[0] += EX->d[0];

         break;

     case 0x59:  /* MULSD Gx, Ex */

@@ -162,6 +168,12 @@ int RunF20F(x64emu_t *emu, rex_t rex)
         nextop = F8;

         GETEX(0);

         GETGX;

+        #ifndef NOALIGN

+            // sub generate a -NAN only if doing inf - inf

+            if((isinf(GX->d[0]) && isinf(EX->d[0]) && (EX->q[0]&0x8000000000000000LL)==(GX->q[0]&0x8000000000000000LL)))

+                GX->d[0] = -NAN;

+            else

+        #endif

         GX->d[0] -= EX->d[0];

         break;

     case 0x5D:  /* MINSD Gx, Ex */