Author: aandrejevic
Date: Fri May 22 21:57:28 2015
New Revision: 67852
URL: 
http://svn.reactos.org/svn/reactos?rev=67852&view=rev
Log:
[FAST486]
Fix multiple FP80-to-int conversion issues.
Modified:
    trunk/reactos/lib/fast486/fpu.c
Modified: trunk/reactos/lib/fast486/fpu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fpu.c?rev=6785…
==============================================================================
--- trunk/reactos/lib/fast486/fpu.c     [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/fpu.c     [iso-8859-1] Fri May 22 21:57:28 2015
@@ -317,7 +317,7 @@
         if (State->FpuControl.Im)
         {
-            *Result = 0LL;
+            *Result = 0x8000000000000000LL;
             return TRUE;
         }
         else
@@ -339,16 +339,15 @@
     {
         /* The result is zero */
         *Result = 0LL;
-
-        if (UnbiasedExp > -64)
-        {
-            Bits = 65 + UnbiasedExp;
-            Remainder = Value->Mantissa >> (64 - Bits);
+        Bits = 64;
+
+        if (UnbiasedExp >= -64)
+        {
+            Remainder = Value->Mantissa >> (-1 - UnbiasedExp);
         }
         else
         {
             /* Too small to even have a remainder */
-            Bits = 1;
             Remainder = 0ULL;
         }
     }
@@ -2536,7 +2535,8 @@
                         return;
                     }
                 }
-                else if (!Fast486FpuToInteger(State, &FPU_ST(0), &Temp))
+
+                if (!Fast486FpuToInteger(State, &FPU_ST(0), &Temp))
                 {
                     /* Exception occurred */
                     return;
@@ -2547,7 +2547,10 @@
                 {
                     State->FpuStatus.Ie = TRUE;
-                    if (State->FpuControl.Im) Temp = 0LL;
+                    if (State->FpuControl.Im)
+                    {
+                        Temp = 0x80000000LL;
+                    }
                     else
                     {
                         Fast486FpuException(State);
@@ -3229,7 +3232,8 @@
                         return;
                     }
                 }
-                else if (!Fast486FpuToInteger(State, &FPU_ST(0), &Temp))
+
+                if (!Fast486FpuToInteger(State, &FPU_ST(0), &Temp))
                 {
                     /* Exception occurred */
                     return;
@@ -3241,7 +3245,10 @@
                     /* Raise the invalid operation exception */
                     State->FpuStatus.Ie = TRUE;
-                    if (State->FpuControl.Im) Temp = 0LL;
+                    if (State->FpuControl.Im)
+                    {
+                        Temp = 0x8000LL;
+                    }
                     else
                     {
                         Fast486FpuException(State);
@@ -3365,7 +3372,8 @@
                         return;
                     }
                 }
-                else if (!Fast486FpuToInteger(State, &FPU_ST(0), &Temp))
+
+                if (!Fast486FpuToInteger(State, &FPU_ST(0), &Temp))
                 {
                     /* Exception occurred */
                     return;