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

  1. /*------------------------------------------------------------------------
  2.  * filename - stat87.cas
  3.  *
  4.  * function(s)
  5.  *        _status87 - gets floating-point status
  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. #ifndef _Windows
  20. #include "emuvars.h"
  21. #endif
  22.  
  23. /*--------------------------------------------------------------------------*
  24.  
  25. Name            _status87 - gets floating-point status
  26.  
  27. Usage           unsigned int _status87(void);
  28.  
  29. Prototype in    float.h
  30.  
  31. Description     _status87 gets the floating-point status word, which is a
  32.                 combination of the 80x87 status word and other
  33.                 conditions detected by the 80x87 exception handler.
  34.  
  35. Return value    The bits in the return value give the floating-point
  36.                 status.  See <float.h> for a complete definition of the bits
  37.                 returned by _status87.
  38.  
  39. Note:
  40. The TC RTL controls the Denormal and Invalid exceptions, because certain
  41. of these errors can be repaired without damage.  If a call to _control87()
  42. attempted to mask these, then the bits are kept in memory instead of on
  43. the coprocessor.
  44.  
  45. Denormal exceptions are never reported, as they can always be repaired.
  46.  
  47. *---------------------------------------------------------------------------*/
  48.  
  49. unsigned int _status87(void)
  50. {
  51.         volatile unsigned int Status;
  52.  
  53. #ifndef _Windows
  54. #pragma warn -asm
  55. asm     emul
  56. #pragma warn .asm
  57. #endif
  58.  
  59. asm     fstsw   Status
  60. asm     fwait
  61. asm     mov     ax, Status
  62.  
  63. #ifndef _Windows
  64. /*
  65. asm     or      al, byte ptr SS: _emu.control [1]
  66. */
  67. asm     or      al, byte ptr SS: _emu.status2 [0]
  68. #endif
  69.  
  70.         return _AX &
  71.                 SW_INVALID+SW_ZERODIVIDE+SW_OVERFLOW+SW_UNDERFLOW+SW_INEXACT;
  72. }
  73.