Fix fpc_frac_real, fpc_trunk_real and fpc_int_real by removing the assumption that SP=BP at entry

git-svn-id: trunk@32865 -
This commit is contained in:
pierre 2016-01-06 15:20:57 +00:00
parent 701a610f4d
commit e835f120e9

View File

@ -215,54 +215,61 @@
function fpc_frac_real(d : ValReal) : ValReal;assembler;compilerproc; function fpc_frac_real(d : ValReal) : ValReal;assembler;compilerproc;
asm asm
sub sp, 2 sub sp, 2
fnstcw [bp-2] mov bx, sp
fnstcw ss:[bx]
fwait fwait
mov cl, [bp-1] mov cl, ss:[bx+1]
or byte [bp-1], $0f or byte ss:[bx+1], $0f
fldcw [bp-2] fldcw ss:[bx]
fld tbyte [d] fld tbyte [d]
frndint frndint
fld tbyte [d] fld tbyte [d]
fsub st, st(1) fsub st, st(1)
fstp st(1) fstp st(1)
mov [bp-1], cl mov ss:[bx+1], cl
fldcw [bp-2] fldcw ss:[bx]
add sp, 2
end; end;
{$define FPC_SYSTEM_HAS_INT} {$define FPC_SYSTEM_HAS_INT}
function fpc_int_real(d : ValReal) : ValReal;assembler;compilerproc; function fpc_int_real(d : ValReal) : ValReal;assembler;compilerproc;
asm asm
sub sp, 2 sub sp, 2
fnstcw [bp-2] mov bx, sp
fnstcw ss:[bx]
fwait fwait
mov cl, byte [bp-1] mov cl, byte ss:[bx+1]
or byte [bp-1], $0f or byte ss:[bx+1], $0f
fldcw [bp-2] fldcw ss:[bx]
fwait fwait
fld tbyte [d] fld tbyte [d]
frndint frndint
fwait fwait
mov byte [bp-1], cl mov byte ss:[bx+1], cl
fldcw [bp-2] fldcw ss:[bx]
add sp, 2
end; end;
{$define FPC_SYSTEM_HAS_TRUNC} {$define FPC_SYSTEM_HAS_TRUNC}
function fpc_trunc_real(d : ValReal) : int64;assembler;compilerproc; function fpc_trunc_real(d : ValReal) : int64;assembler;compilerproc;
asm asm
sub sp, 10 sub sp, 10
mov bx, sp
fld tbyte [d] fld tbyte [d]
fnstcw [bp-10] fnstcw ss:[bx]
mov cl, [bp-9] mov cl, ss:[bx+1]
or byte [bp-9], $0f or byte ss:[bx+1], $0f
fldcw [bp-10] fldcw ss:[bx]
mov [bp-9], cl mov ss:[bx+1], cl
fistp qword [bp-8] fistp qword ss:[bx+2]
fldcw [bp-10] fldcw ss:[bx]
fwait fwait
mov dx, [bp-8] mov dx, ss:[bx+2]
mov cx, [bp-6] mov cx, ss:[bx+4]
mov bx, [bp-4] mov ax, ss:[bx+8]
mov ax, [bp-2] { store bx as last }
mov bx, ss:[bx+6]
add sp, 10
end; end;
{$define FPC_SYSTEM_HAS_ROUND} {$define FPC_SYSTEM_HAS_ROUND}