]>
Commit | Line | Data |
---|---|---|
f7eac6eb | 1 | /* |
f7eac6eb RM |
2 | * Public domain. |
3 | */ | |
4 | ||
5 | #include <machine/asm.h> | |
6 | ||
7 | RCSID("$NetBSD: s_ilogb.S,v 1.5 1995/10/12 15:53:09 jtc Exp $") | |
8 | ||
76da7265 | 9 | ENTRY(__ieee754_ilogb) |
d705269e | 10 | fldl 4(%esp) |
601d2942 UD |
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. */ | |
76da7265 AZ |
20 | cmpb $0x40, %dh |
21 | je 2f /* Is +-0, jump. */ | |
601d2942 | 22 | |
f7eac6eb | 23 | fxtract |
d705269e | 24 | pushl %eax |
fee732e5 | 25 | cfi_adjust_cfa_offset (4) |
0e19d4a3 | 26 | fstp %st |
f7eac6eb | 27 | |
d705269e | 28 | fistpl (%esp) |
36775c3b | 29 | fwait |
d705269e | 30 | popl %eax |
fee732e5 | 31 | cfi_adjust_cfa_offset (-4) |
f7eac6eb | 32 | |
f7eac6eb | 33 | ret |
601d2942 UD |
34 | |
35 | 1: fstp %st | |
36 | movl $0x7fffffff, %eax | |
37 | ret | |
76da7265 AZ |
38 | 2: fstp %st |
39 | movl $0x80000000, %eax /* FP_ILOGB0 */ | |
40 | ret | |
41 | END (__ieee754_ilogb) |