home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / MATH / HYPOT.S < prev    next >
Encoding:
Text File  |  1993-01-02  |  1000 b   |  37 lines

  1. / hypot.s (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes
  2.  
  3. / As the arguments are double and the computation is done in extended
  4. / format, an interative method is not required to avoid overflow.
  5.  
  6. #include <libm.h>
  7.  
  8.         .globl  _hypot
  9.  
  10.         .text
  11.  
  12.         .align  2, 0x90
  13.  
  14. / double hypot (double x, double y)
  15.  
  16. #define x        4(%esp)
  17. #define y       12(%esp)
  18.  
  19. _hypot:
  20.         fldl    x                       / x
  21.         fld     %st                     / x, x
  22.         fmulp                           / x*x
  23.         fldl    y                       / y, x*x
  24.         fld     %st                     / y, y, x*x
  25.         fmulp                           / y*y, x*x
  26.         faddp                           / y*y + x*x
  27.         fsqrt                           / hypot (x, y)
  28.         fstpl   x                       / convert to double
  29.         fldl    x
  30.         _xam
  31.         j_inf   1f
  32.         ret
  33.  
  34.         .align  2, 0x90
  35. 1:      SETERRNO($ERANGE)
  36.         ret
  37.