Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Written by J.T. Conklin <jtc@netbsd.org>.
  3.  * Public domain.
  4.  */
  5.  
  6.  
  7.         .file   "ilogb.S"
  8.         .text
  9.         .align 4
  10. .globl _ilogb
  11.         .def    _ilogb; .scl    2;      .type   32;     .endef
  12. _ilogb:
  13.  
  14.         fldl    4(%esp)
  15. /* I added the following ugly construct because ilogb(+-Inf) is
  16.    required to return INT_MAX in ISO C99.
  17.    -- jakub@redhat.com.  */
  18.         fxam                    /* Is NaN or +-Inf?  */
  19.         fstsw   %ax
  20.         movb    $0x45, %dh
  21.         andb    %ah, %dh
  22.         cmpb    $0x05, %dh
  23.         je      1f              /* Is +-Inf, jump.  */
  24.  
  25.         fxtract
  26.         pushl   %eax
  27.         fstp    %st
  28.  
  29.         fistpl  (%esp)
  30.         fwait
  31.         popl    %eax
  32.  
  33.         ret
  34.  
  35. 1:      fstp    %st
  36.         movl    $0x7fffffff, %eax
  37.         ret
  38.