home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / MATHSRC.ZIP / CLEAR87.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  2.1 KB  |  80 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - clear87.cas
  3.  *
  4.  * function(s)
  5.  *        _clear87 - clears floating-point status word
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16. #pragma inline
  17.  
  18. #include <float.h>
  19. #include <dos.h>
  20. #ifndef _Windows
  21. #include "emuvars.h"
  22. #endif
  23.  
  24. /*--------------------------------------------------------------------------*
  25.  
  26. Name            _clear87 - clears floating-point status word
  27.  
  28. Usage           unsigned int _clear87(void);
  29.  
  30. Prototype in    float.h
  31.  
  32. Description     _clear87 clears the floating-point status word, which is a
  33.                 combination of the 80x87 status word and other
  34.                 conditions detected by the 80x87 exception handler.
  35.  
  36. Return value    The bits in the value returned indicate the old floating-
  37.                 point status. See float.h for a complete definition of the
  38.                 bits returned by _clear87.
  39.  
  40. Note:
  41. The C RTL controls the Denormal and Invalid exceptions, because certain
  42. of these errors can be repaired without damage.  If a call to _control87()
  43. attempted to mask these, then the bits are kept in memory instead of on
  44. the coprocessor.
  45.  
  46. Denormal exceptions are never reported, as they can always be repaired.
  47.  
  48. *---------------------------------------------------------------------------*/
  49.  
  50. unsigned int _clear87 (void)
  51. {
  52.         volatile unsigned int Status;
  53.  
  54. #ifndef _Windows
  55. #pragma warn -asm
  56. asm     emul
  57. #pragma warn .asm
  58. #endif
  59.  
  60. /* get the chip status */
  61. asm     FSTSW   Status
  62.  
  63. /* and the shadow status, clearing it */
  64. asm     sub     ax, ax
  65.  
  66. #ifndef _Windows
  67. /*
  68. asm     xchg    al, byte ptr SS: _emu.control [1]
  69. */
  70. asm     xchg    al, byte ptr SS: _emu.status2 [0]
  71. #endif
  72.  
  73. /* clear the chip */
  74. asm     FCLEX
  75.  
  76. asm     or      ax, Status
  77.         return _AX &
  78.                 SW_INVALID+SW_ZERODIVIDE+SW_OVERFLOW+SW_UNDERFLOW+SW_INEXACT;
  79. }
  80.