Просмотр исходного кода

+ i386 assembler implementations of tan, cotan, sincos
* default tan, cotan use now sincos

git-svn-id: trunk@5809 -

florian 18 лет назад
Родитель
Сommit
4b88079c41
2 измененных файлов с 48 добавлено и 6 удалено
  1. 32 0
      rtl/i386/mathu.inc
  2. 16 6
      rtl/objpas/math.pp

+ 32 - 0
rtl/i386/mathu.inc

@@ -21,6 +21,38 @@ function arctan2(y,x : float) : float;assembler;
      fpatan
      fwait
   end;
+  
+  
+{$define FPC_MATH_HAS_SINCOS}
+procedure sincos(theta : float;out sinus,cosinus : float);assembler;
+  asm
+    fldt theta
+    fsincos
+    fstpt (%edx)
+    fstpt (%eax)
+    fwait
+  end;
+
+
+{$define FPC_MATH_HAS_TAN}  
+function tan(x : float) : float;assembler;
+  asm
+    fldt X
+    fptan
+    fstp %st
+    fwait
+  end;
+  
+
+{$define FPC_MATH_HAS_COTAN}
+function cotan(x : float) : float;assembler;
+  asm
+    fldt X
+    fptan
+    fdivrp
+    fwait
+  end;
+
 
 function GetRoundMode: TFPURoundingMode;
 begin

+ 16 - 6
rtl/objpas/math.pp

@@ -656,25 +656,35 @@ function radtocycle(rad : float) : float;
      radtocycle:=rad*(1/(2*pi));
   end;
 
+{$ifndef FPC_MATH_HAS_TAN}
 function tan(x : float) : float;
-
+  var
+    _sin,_cos : float;
   begin
-     Tan:=Sin(x)/Cos(x)
+    sincos(x,_Sin,_Cos);
+    cotan:=_Sin/_Cos;
   end;
+{$endif FPC_MATH_HAS_TAN}
 
-function cotan(x : float) : float;
 
+{$ifndef FPC_MATH_HAS_COTAN}
+function cotan(x : float) : float;
+  var
+    _sin,_cos : float;
   begin
-     cotan:=Cos(X)/Sin(X);
+    sincos(x,_Sin,_Cos);
+    cotan:=_Cos/_Sin;
   end;
+{$endif FPC_MATH_HAS_COTAN}
 
-procedure sincos(theta : float;out sinus,cosinus : float);
 
+{$ifndef FPC_MATH_HAS_SINCOS}
+procedure sincos(theta : float;out sinus,cosinus : float);
   begin
     sinus:=sin(theta);
     cosinus:=cos(theta);
   end;
-
+{$endif FPC_MATH_HAS_SINCOS}
 
 
 { ArcSin and ArcCos from Arjan van Dijk ([email protected]) }