| 1 | /* |
| 2 | * Public domain. |
| 3 | */ |
| 4 | |
| 5 | #include <machine/asm.h> |
| 6 | |
| 7 | RCSID("$NetBSD: s_ilogbf.S,v 1.4 1995/10/22 20:32:43 pk Exp $" ) |
| 8 | |
| 9 | ENTRY(__ieee754_ilogbf) |
| 10 | flds 4(%esp) |
| 11 | /* I added the following ugly construct because ilogb(+-Inf) is |
| 12 | required to return INT_MAX in ISO C99. |
| 13 | -- jakub@redhat.com. */ |
| 14 | fxam /* Is NaN or +-Inf? */ |
| 15 | fstsw %ax |
| 16 | movb $0x45, %dh |
| 17 | andb %ah, %dh |
| 18 | cmpb $0x05, %dh |
| 19 | je 1f /* Is +-Inf, jump. */ |
| 20 | cmpb $0x40, %dh |
| 21 | je 2f /* Is +-0, jump. */ |
| 22 | |
| 23 | fxtract |
| 24 | pushl %eax |
| 25 | cfi_adjust_cfa_offset (4) |
| 26 | fstp %st |
| 27 | |
| 28 | fistpl (%esp) |
| 29 | fwait |
| 30 | popl %eax |
| 31 | cfi_adjust_cfa_offset (-4) |
| 32 | |
| 33 | ret |
| 34 | |
| 35 | 1: fstp %st |
| 36 | movl $0x7fffffff, %eax |
| 37 | ret |
| 38 | 2: fstp %st |
| 39 | movl $0x80000000, %eax /* FP_ILOGB0 */ |
| 40 | ret |
| 41 | END (__ieee754_ilogbf) |
| 42 | |