diff --git a/rtl/i386/i386.inc b/rtl/i386/i386.inc index c2e3509a7d..f6534abe18 100644 --- a/rtl/i386/i386.inc +++ b/rtl/i386/i386.inc @@ -1216,16 +1216,24 @@ const {$define FPC_SYSTEM_HAS_SYSRESETFPU} Procedure SysResetFPU;{$ifdef SYSTEMINLINE}inline;{$endif} + var + { these locals are so we don't have to hack pic code in the assembler } + localmxcsr: dword; + localfpucw: word; begin + localfpucw:=Default8087CW; asm fninit - fldcw Default8087CW + fldcw localfpucw fwait end; if has_sse_support then - asm - { setup sse exceptions } - ldmxcsr mxcsr + begin + localmxcsr:=mxcsr; + asm + { setup sse exceptions } + ldmxcsr localmxcsr + end; end; softfloat_exception_flags:=0; softfloat_exception_mask:=float_flag_underflow or float_flag_inexact or float_flag_denormal; diff --git a/rtl/i386/math.inc b/rtl/i386/math.inc index 93cf10882b..07be7aeb0d 100644 --- a/rtl/i386/math.inc +++ b/rtl/i386/math.inc @@ -17,14 +17,15 @@ FPU Control word ****************************************************************************} - procedure Set8087CW(cw:word);assembler; - asm -{$ifndef REGCALL} - movw cw,%ax -{$endif} - movw %ax,default8087cw - fnclex - fldcw default8087cw + procedure Set8087CW(cw:word); + begin + { pic-safe ; cw will not be a regvar because it's accessed from } + { assembler } + default8087cw:=cw; + asm + fnclex + fldcw cw + end; end; @@ -120,20 +121,22 @@ {$define FPC_SYSTEM_HAS_EXP} function fpc_exp_real(d : ValReal) : ValReal;assembler;compilerproc; + var + cw1,cw2: word; asm // comes from DJ GPP fldt d fldl2e fmulp %st,%st(1) - fstcw .LCW1 - fstcw .LCW2 + fstcw CW1 + fstcw CW2 fwait - andw $0xf3ff,.LCW2 - orw $0x0400,.LCW2 - fldcw .LCW2 + andw $0xf3ff,CW2 + orw $0x0400,CW2 + fldcw CW2 fld %st(0) frndint - fldcw .LCW1 + fldcw CW1 fxch %st(1) fsub %st(1),%st f2xm1 @@ -142,15 +145,6 @@ fscale fstp %st(1) fclex - jmp .LCW3 - // store some help data in the data segment - .data - .LCW1: - .word 0 - .LCW2: - .word 0 - .text - .LCW3: end;