mathu.inc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2003 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. function GetRoundMode: TFPURoundingMode;
  13. begin
  14. Result := TFPURoundingMode((Get8087CW shr 10) and 3);
  15. end;
  16. function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
  17. var
  18. CtlWord: Word;
  19. begin
  20. CtlWord := Get8087CW;
  21. Set8087CW((CtlWord and $F3FF) or (Ord(RoundMode) shl 10));
  22. Result := TFPURoundingMode((CtlWord shr 10) and 3);
  23. end;
  24. function GetPrecisionMode: TFPUPrecisionMode;
  25. begin
  26. Result := TFPUPrecisionMode((Get8087CW shr 8) and 3);
  27. end;
  28. function SetPrecisionMode(const Precision: TFPUPrecisionMode): TFPUPrecisionMode;
  29. var
  30. CtlWord: Word;
  31. begin
  32. CtlWord := Get8087CW;
  33. Set8087CW((CtlWord and $FCFF) or (Ord(Precision) shl 8));
  34. Result := TFPUPrecisionMode((CtlWord shr 8) and 3);
  35. end;
  36. function GetExceptionMask: TFPUExceptionMask;
  37. begin
  38. Result := TFPUExceptionMask(Get8087CW and $3F);
  39. end;
  40. function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
  41. var
  42. CtlWord: Word;
  43. begin
  44. CtlWord := Get8087CW;
  45. Set8087CW( (CtlWord and $FFC0) or Byte(Longint(Mask)) );
  46. Result := TFPUExceptionMask(CtlWord and $3F);
  47. end;
  48. procedure ClearExceptions(RaisePending: Boolean);assembler;
  49. asm
  50. cmpb $0,RaisePending
  51. je .Lclear
  52. fwait
  53. .Lclear:
  54. fnclex
  55. end;
  56. {
  57. $Log$
  58. Revision 1.1 2003-04-24 09:16:31 florian
  59. * initial implementation with code from math.pp
  60. }