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

  1. /*------------------------------------------------------------------------
  2.  * filename - clear87.cas
  3.  *
  4.  * function(s)
  5.  *        _clear87 - clears floating-point status word
  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 <dos.h>
  22. #include "emuvars.h"
  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 TC 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. #pragma    warn -asm
  54. asm    emul
  55. #pragma    warn .asm
  56.  
  57. /* get the chip status */
  58. asm    FSTSW    Status
  59.  
  60. /* and the shadow status, clearing it */
  61. asm    sub    ax, ax
  62. /*
  63. asm    xchg    al, byte ptr SS: _emu.control [1]
  64. */
  65. asm    xchg    al, byte ptr SS: _emu.status2 [0]
  66.  
  67. /* clear the chip */
  68. asm    FCLEX
  69.  
  70. asm    or    ax, Status
  71.     return _AX &
  72.         SW_INVALID+SW_ZERODIVIDE+SW_OVERFLOW+SW_UNDERFLOW+SW_INEXACT;
  73. }
  74.