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

  1. / rint.s (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes
  2.  
  3.         .globl  _rint
  4.  
  5.         .text
  6.  
  7.         .align  2, 0x90
  8.  
  9. / double rint (double x)
  10.  
  11. #define cw1       0(%esp)
  12. #define cw2       2(%esp)
  13. /define ret_addr  4(%esp)
  14. #define x         8(%esp)
  15.  
  16. _rint:
  17.         subl    $4, %esp
  18.         fstcww  cw1
  19.         movw    cw1, %ax
  20.         andw    $0xf3ff, %ax            / round to nearest or even
  21.         movw    %ax, cw2
  22.         fldcww  cw2
  23.         fldl    x                       / x
  24.         frndint
  25.         fldcww  cw1
  26.         addl    $4, %esp
  27.         ret
  28.