* x87 optimized version of math.log2() for i8086, i386 and x86_64

git-svn-id: trunk@26266 -
This commit is contained in:
nickysn 2013-12-22 23:21:41 +00:00
parent 90b69184f1
commit 4eb9043ac7
4 changed files with 32 additions and 0 deletions

View File

@ -74,6 +74,16 @@ function cotan(x : float) : float;assembler;
end;
{$define FPC_MATH_HAS_LOG2}
function log2(x : float) : float;assembler;
asm
fld1
fldt x
fyl2x
fwait
end;
{$define FPC_MATH_HAS_DIVMOD}
procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);assembler;
asm

View File

@ -79,6 +79,16 @@ procedure sincos(theta : single;out sinus,cosinus : single);assembler;
end;}
{$define FPC_MATH_HAS_LOG2}
function log2(x : float) : float;assembler;
asm
fld1
fld tbyte [x]
fyl2x
fwait
end;
{//$define FPC_MATH_HAS_DIVMOD}
{procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);assembler;
asm

View File

@ -851,10 +851,12 @@ function log10(x : float) : float;
log10:=ln(x)*0.43429448190325182765; { 1/ln(10) }
end;
{$ifndef FPC_MATH_HAS_LOG2}
function log2(x : float) : float;
begin
log2:=ln(x)*1.4426950408889634079; { 1/ln(2) }
end;
{$endif FPC_MATH_HAS_LOG2}
function logn(n,x : float) : float;
begin

View File

@ -42,6 +42,16 @@ function cotan(x : float) : float;assembler;
fdivp %st,%st(1)
fwait
end;
{$define FPC_MATH_HAS_LOG2}
function log2(x : float) : float;assembler;
asm
fld1
fldt x
fyl2x
fwait
end;
{$endif FPC_HAS_TYPE_EXTENDED}