home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / libsrc / m / src / atan2.s < prev    next >
Encoding:
Text File  |  1993-09-04  |  1.1 KB  |  54 lines

  1. /* This is file ATAN2.S */
  2. /*
  3. ** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. **
  5. ** This file is distributed under the terms listed in the document
  6. ** "copying.dj", available from DJ Delorie at the address above.
  7. ** A copy of "copying.dj" should accompany this file; if not, a copy
  8. ** should be available from where this file was obtained.  This file
  9. ** may not be distributed without a verbatim copy of "copying.dj".
  10. **
  11. ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. */
  14.  
  15. /*
  16.  * Modified by Dieter Buerssner to return NaN (not a number)
  17.  * for atan2(0,0). (fpatan would yield 0.0 with no exceptions set)
  18.  */
  19.  
  20. .data
  21.     .align    2
  22. nan:
  23.     .long    0xffffffff
  24.     .byte    0xff
  25.     .byte    0xff
  26.     .byte    0xff
  27.     .byte    0x7f
  28.  
  29. .text
  30.     .globl    _atan2
  31. _atan2:
  32.     fldl    4(%esp)
  33.     fldl    12(%esp)
  34.     ftst
  35.     fnstsw    %ax
  36.     sahf
  37.     jne    doit
  38.     fxch    %st(1)
  39.     ftst
  40.     fnstsw    %ax
  41.     sahf
  42.     je    isanan
  43.     fxch    %st(1)
  44. doit:
  45.     fpatan
  46.     ret
  47. isanan:
  48.     movl    $33,_errno
  49.     fstp    %st(0)
  50.     fstp    %st(0)
  51.     fldl    nan
  52.     ret
  53.  
  54.