about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-01-27 13:26:15 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-01-27 13:26:15 +0100
commit28ef6cdefc2d3a8803c6dc148e172c70b1c11175 (patch)
tree5ee9f24d3d1aa8a445fb0b99a18988f1cdb9d338 /src
parent5e38ea28b6f21ceeaeaf05cca2c632b35698a236 (diff)
downloadbox64-28ef6cdefc2d3a8803c6dc148e172c70b1c11175.tar.gz
box64-28ef6cdefc2d3a8803c6dc148e172c70b1c11175.zip
Improved fxam helper
Diffstat (limited to 'src')
-rw-r--r--src/emu/x87emu_private.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/emu/x87emu_private.h b/src/emu/x87emu_private.h
index a8e2d39c..6b62fe48 100644
--- a/src/emu/x87emu_private.h
+++ b/src/emu/x87emu_private.h
@@ -128,33 +128,45 @@ static inline double fpu_round(x64emu_t* emu, double d) {
 
 static inline void fpu_fxam(x64emu_t* emu) {
     emu->sw.f.F87_C1 = (ST0.ud[1]&0x80000000)?1:0;
-    if(!emu->fpu_stack) {
+    if(emu->fpu_stack<=0) {
+        //Empty
         emu->sw.f.F87_C3 = 1;
         emu->sw.f.F87_C2 = 0;
         emu->sw.f.F87_C0 = 1;
         return;
     }
-    if(isinf(ST0.d)) 
-    {  // TODO: Unsupported and denormal not analysed...
+    if(isinf(ST0.d))
+    {
+        //Infinity
         emu->sw.f.F87_C3 = 0;
         emu->sw.f.F87_C2 = 1;
         emu->sw.f.F87_C0 = 1;
         return;
     }
     if(isnan(ST0.d))
-    {  // TODO: Unsupported and denormal not analysed...
+    {
+        //NaN
         emu->sw.f.F87_C3 = 0;
         emu->sw.f.F87_C2 = 0;
         emu->sw.f.F87_C0 = 1;
         return;
     }
-    if(ST0.d==0.0)
+    if((ST0.ud[0]|(ST0.ud[1]&0x7fffffff))==0)
     {
+        //Zero
         emu->sw.f.F87_C3 = 1;
         emu->sw.f.F87_C2 = 0;
         emu->sw.f.F87_C0 = 0;
         return;
     }
+    if((ST0.ud[1]&0x7FF00000)==0)
+    {
+        // denormals
+        emu->sw.f.F87_C3 = 1;
+        emu->sw.f.F87_C2 = 1;
+        emu->sw.f.F87_C0 = 0;
+        return;
+    }
     // normal...
     emu->sw.f.F87_C3 = 0;
     emu->sw.f.F87_C2 = 1;