123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- {
- $Id$
- This file is part of the Free Pascal run time library.
- Copyright (c) 1999-2003 by Florian Klaempfl
- member of the Free Pascal development team
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- {$ASMMODE ATT}
- {$define FPC_MATH_HAS_ARCTAN2}
- function arctan2(y,x : float) : float;assembler;
- asm
- fldt y
- fldt x
- fpatan
- fwait
- end;
- procedure SetSSECSR(w : dword);
- var
- _w : dword;
- begin
- _w:=w;
- asm
- ldmxcsr _w
- end;
- end;
- function GetSSECSR : dword;
- var
- _w : dword;
- begin
- asm
- stmxcsr _w
- end;
- result:=_w;
- end;
- function GetRoundMode: TFPURoundingMode;
- begin
- Result := TFPURoundingMode((Get8087CW shr 10) and 3);
- end;
- function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
- var
- CtlWord: Word;
- begin
- CtlWord := Get8087CW;
- Set8087CW((CtlWord and $F3FF) or (Ord(RoundMode) shl 10));
- Result := TFPURoundingMode((CtlWord shr 10) and 3);
- end;
- function GetPrecisionMode: TFPUPrecisionMode;
- begin
- Result := TFPUPrecisionMode((Get8087CW shr 8) and 3);
- end;
- function SetPrecisionMode(const Precision: TFPUPrecisionMode): TFPUPrecisionMode;
- var
- CtlWord: Word;
- begin
- CtlWord := Get8087CW;
- Set8087CW((CtlWord and $FCFF) or (Ord(Precision) shl 8));
- Result := TFPUPrecisionMode((CtlWord shr 8) and 3);
- end;
- function GetExceptionMask: TFPUExceptionMask;
- begin
- Result := TFPUExceptionMask(Longint(Get8087CW and $3F));
- end;
- function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
- var
- CtlWord: Word;
- begin
- CtlWord := Get8087CW;
- Set8087CW( (CtlWord and $FFC0) or Byte(Longint(Mask)) );
- Result := TFPUExceptionMask(Longint(CtlWord and $3F));
- end;
- procedure ClearExceptions(RaisePending: Boolean);assembler;
- asm
- cmpb $0,RaisePending
- je .Lclear
- fwait
- .Lclear:
- fnclex
- end;
- {
- $Log$
- Revision 1.5 2004-11-02 15:26:21 florian
- * fixed sse exception handling
- Revision 1.4 2004/05/09 15:47:56 peter
- * fixed wrong typecasts
- Revision 1.3 2003/10/31 09:20:11 mazen
- + assembler mode forced to ATT style for x86 cpu
- Revision 1.2 2003/10/26 15:58:05 florian
- * fixed arctan2 to handle x=0 correctly as well
- Revision 1.1 2003/04/24 09:16:31 florian
- * initial implementation with code from math.pp
- }
|