Forráskód Böngészése

* cause bits must be clear as flags to avoid a second FPU exception

git-svn-id: trunk@21844 -
pierre 13 éve
szülő
commit
c234eae68a
2 módosított fájl, 10 hozzáadás és 3 törlés
  1. 6 1
      rtl/mips/mathu.inc
  2. 4 2
      rtl/mips/mips.inc

+ 6 - 1
rtl/mips/mathu.inc

@@ -27,6 +27,8 @@ const
   default_fpu_enable = fpu_enable_div_zero or fpu_enable_invalid;
 
   fpu_flags_mask = $7C;
+  fpu_cause_mask = $3F000;
+
   { FPU rounding mask and values }
   fpu_rounding_mask    = $3;
   fpu_rounding_nearest = 0;
@@ -166,6 +168,9 @@ function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
     else
       fsr:=fsr or (fpu_enable_inexact);
 
+    { Reset flags and cause }
+    fsr := fsr and not (fpu_flags_mask or fpu_cause_mask);
+
     { update control register contents }
     set_fsr(fsr);
 
@@ -175,6 +180,6 @@ function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
 
 procedure ClearExceptions(RaisePending: Boolean =true);
   begin
-    set_fsr(get_fsr and $fffffc1f);
+    set_fsr(get_fsr and not (fpu_flags_mask or fpu_cause_mask));
   end;
 

+ 4 - 2
rtl/mips/mips.inc

@@ -48,6 +48,8 @@ const
   default_fpu_enable = fpu_enable_div_zero or fpu_enable_invalid;
 
   fpu_flags_mask = $7C;
+  fpu_cause_mask = $3F000;
+
   { FPU rounding mask and values }
   fpu_rounding_mask    = $3;
   fpu_rounding_nearest = 0;
@@ -67,8 +69,8 @@ var
         { enable div by 0 and invalid operation fpu exceptions,
           disable the other exceptions }
         tmp32 := (tmp32 and not fpu_enable_mask) or default_fpu_enable;
-        { Reset flags }
-        tmp32 := tmp32 and not fpu_flags_mask;
+        { Reset flags and cause }
+        tmp32 := tmp32 and not (fpu_flags_mask or fpu_cause_mask);
 
         { round towards nearest; ieee compliant arithmetics }
         tmp32 := (tmp32 and not fpu_rounding_mask) or fpu_rounding_nearest;