home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / MATH.ZIP / STAT87.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  2.2 KB  |  68 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - stat87.cas
  3.  *
  4.  * function(s)
  5.  *        _status87 - gets floating-point status
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987, 1990 by Borland International        |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18. #pragma inline
  19.  
  20. #include <float.h>
  21. #include "emuvars.h"
  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. #pragma    warn -asm
  54. asm    emul
  55. #pragma    warn .asm
  56.  
  57. asm    fstsw    Status
  58. asm    fwait
  59. asm    mov    ax, Status
  60. /*
  61. asm    or    al, byte ptr SS: _emu.control [1]
  62. */
  63. asm    or    al, byte ptr SS: _emu.status2 [0]
  64.  
  65.     return _AX &
  66.         SW_INVALID+SW_ZERODIVIDE+SW_OVERFLOW+SW_UNDERFLOW+SW_INEXACT;
  67. }
  68.