Browse Source

* fix SetRoundingMode on RiscV64

git-svn-id: branches/laksen/riscv_new@39646 -
florian 7 years ago
parent
commit
70b2e11e6a
1 changed files with 8 additions and 6 deletions
  1. 8 6
      rtl/riscv64/mathu.inc

+ 8 - 6
rtl/riscv64/mathu.inc

@@ -12,13 +12,15 @@
 
 
 **********************************************************************}
 **********************************************************************}
 
 
-function getfpcr: dword; nostackframe; assembler;
+function getrm: dword; nostackframe; assembler;
   asm
   asm
+    frrm a0
   end;
   end;
 
 
 
 
-procedure setfpcr(val: dword); nostackframe; assembler;
+procedure setrm(val: dword); nostackframe; assembler;
   asm
   asm
+    fsrm a0
   end;
   end;
 
 
 
 
@@ -36,19 +38,19 @@ procedure setfflags(flags : dword); nostackframe; assembler;
 
 
 function GetRoundMode: TFPURoundingMode;
 function GetRoundMode: TFPURoundingMode;
   const
   const
-    bits2rm: array[0..3] of TFPURoundingMode = (rmNearest,rmUp,rmDown,rmTruncate);
+    bits2rm: array[0..3] of TFPURoundingMode = (rmNearest,rmTruncate,rmDown,rmUp);
   begin
   begin
-    result:=TFPURoundingMode(bits2rm[(getfpcr shr 22) and 3])
+    result:=TFPURoundingMode(bits2rm[getrm])
   end;
   end;
 
 
 
 
 function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
 function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
   const
   const
-    rm2bits: array[TFPURoundingMode] of byte = (0,2,1,3);
+    rm2bits : array[TFPURoundingMode] of byte = (0,2,3,1);
   begin
   begin
     softfloat_rounding_mode:=RoundMode;
     softfloat_rounding_mode:=RoundMode;
     SetRoundMode:=RoundMode;
     SetRoundMode:=RoundMode;
-    setfpcr((getfpcr and $ff3fffff) or (rm2bits[RoundMode] shl 22));
+    setrm(rm2bits[RoundMode]);
   end;
   end;