* some floating point routines improved

This commit is contained in:
florian 2005-03-13 17:14:46 +00:00
parent 454fefefbc
commit f94047b703

View File

@ -121,36 +121,38 @@
{$else} {$else}
function exp(d : ValReal) : ValReal;assembler;[internconst:fpc_in_const_exp]; function exp(d : ValReal) : ValReal;assembler;[internconst:fpc_in_const_exp];
{$endif} {$endif}
asm asm
// comes from DJ GPP // comes from DJ GPP
fldt d fldt d
fldl2e fldl2e
fmulp %st,%st(1) fmulp %st,%st(1)
fstcw .LCW1 fstcw .LCW1
fstcw .LCW2 fstcw .LCW2
andw $0xf3ff,.LCW2 fwait
orw $0x0400,.LCW2 andw $0xf3ff,.LCW2
fldcw .LCW2 orw $0x0400,.LCW2
fld %st(0) fldcw .LCW2
frndint fld %st(0)
fldcw .LCW1 frndint
fxch %st(1) fldcw .LCW1
fsub %st(1),%st fxch %st(1)
f2xm1 fsub %st(1),%st
fld1 f2xm1
faddp %st,%st(1) fld1
fscale faddp %st,%st(1)
fstp %st(1) fscale
jmp .LCW3 fstp %st(1)
// store some help data in the data segment fclex
.data jmp .LCW3
.LCW1: // store some help data in the data segment
.word 0 .data
.LCW2: .LCW1:
.word 0 .word 0
.text .LCW2:
.LCW3: .word 0
end; .text
.LCW3:
end;
{$define FPC_SYSTEM_HAS_FRAC} {$define FPC_SYSTEM_HAS_FRAC}
@ -160,21 +162,19 @@
function frac(d : ValReal) : ValReal;assembler;[internconst:fpc_in_const_frac]; function frac(d : ValReal) : ValReal;assembler;[internconst:fpc_in_const_frac];
{$endif} {$endif}
asm asm
subl $16,%esp subl $16,%esp
fnstcw -4(%ebp) fnstcw -4(%ebp)
fwait fwait
movw -4(%ebp),%cx movw -4(%ebp),%cx
orw $0x0c3f,%cx orw $0x0f00,%cx
movw %cx,-8(%ebp) movw %cx,-8(%ebp)
fldcw -8(%ebp) fldcw -8(%ebp)
fwait fldt d
fldt d frndint
frndint fldt d
fldt d fsub %st(1),%st
fsub %st(1),%st fstp %st(1)
fstp %st(1) fldcw -4(%ebp)
fclex
fldcw -4(%ebp)
end; end;
@ -185,18 +185,18 @@
function int(d : ValReal) : ValReal;assembler;[internconst:fpc_in_const_int]; function int(d : ValReal) : ValReal;assembler;[internconst:fpc_in_const_int];
{$endif} {$endif}
asm asm
subl $16,%esp subl $16,%esp
fnstcw -4(%ebp) fnstcw -4(%ebp)
fwait fwait
movw -4(%ebp),%cx movw -4(%ebp),%cx
orw $0x0c3f,%cx orw $0x0f00,%cx
movw %cx,-8(%ebp) movw %cx,-8(%ebp)
fldcw -8(%ebp) fldcw -8(%ebp)
fwait fwait
fldt d fldt d
frndint frndint
fclex fwait
fldcw -4(%ebp) fldcw -4(%ebp)
end; end;
@ -212,19 +212,18 @@
newcw : word; newcw : word;
res : int64; res : int64;
asm asm
fnstcw oldcw fnstcw oldcw
fwait fwait
movw oldcw,%cx movw oldcw,%cx
orw $0x0c3f,%cx orw $0x0f00,%cx
movw %cx,newcw movw %cx,newcw
fldcw newcw fldcw newcw
fwait fldt d
fldt d fistpq res
fistpq res fwait
movl res,%eax movl res,%eax
movl res+4,%edx movl res+4,%edx
fclex fldcw oldcw
fldcw oldcw
end; end;
@ -240,22 +239,13 @@
{$endif hascompilerproc} {$endif hascompilerproc}
{$endif} {$endif}
var var
oldcw,
newcw : word;
res : int64; res : int64;
asm asm
fnstcw oldcw fldt d
fwait fistpq res
movw $0x1372,newcw fwait
fclex movl res,%eax
fldcw newcw movl res+4,%edx
fwait
fldt d
fistpq res
movl res,%eax
movl res+4,%edx
fclex
fldcw oldcw
end; end;
@ -288,7 +278,10 @@
{ {
$Log$ $Log$
Revision 1.23 2005-03-09 20:50:11 florian Revision 1.24 2005-03-13 17:14:46 florian
* some floating point routines improved
Revision 1.23 2005/03/09 20:50:11 florian
* C. Western: utf-8 reading from resource files * C. Western: utf-8 reading from resource files
Revision 1.22 2005/02/14 17:13:22 peter Revision 1.22 2005/02/14 17:13:22 peter