]>
Commit | Line | Data |
---|---|---|
d38cd08c UD |
1 | /* |
2 | * Written by J.T. Conklin <jtc@netbsd.org>. | |
3 | * Public domain. | |
4 | * Adapted for float type by Ulrich Drepper <drepper@cygnus.com>. | |
d705269e UD |
5 | * |
6 | * Correct handling of y==-inf <drepper@gnu> | |
d38cd08c UD |
7 | */ |
8 | ||
9 | #include <machine/asm.h> | |
10 | ||
d705269e UD |
11 | #ifdef __ELF__ |
12 | .section .rodata | |
13 | #else | |
14 | .text | |
15 | #endif | |
16 | ||
17 | .align ALIGNARG(4) | |
18 | ASM_TYPE_DIRECTIVE(zero_nan,@object) | |
19 | zero_nan: | |
20 | .double 0.0 | |
21 | nan: .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f | |
d705269e UD |
22 | .byte 0, 0, 0, 0, 0, 0, 0, 0x80 |
23 | .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f | |
24 | ASM_SIZE_DIRECTIVE(zero_nan) | |
25 | ||
26 | ||
27 | #ifdef PIC | |
0ac5ae23 UD |
28 | # define MO(op) op##@GOTOFF(%ecx) |
29 | # define MOX(op,x,f) op##@GOTOFF(%ecx,x,f) | |
d705269e | 30 | #else |
0ac5ae23 UD |
31 | # define MO(op) op |
32 | # define MOX(op,x,f) op(,x,f) | |
d705269e UD |
33 | #endif |
34 | ||
35 | ||
36 | .text | |
d38cd08c UD |
37 | ENTRY(__ieee754_scalbf) |
38 | flds 8(%esp) | |
d705269e UD |
39 | fxam |
40 | fnstsw | |
d38cd08c | 41 | flds 4(%esp) |
d705269e UD |
42 | andl $0x4700, %eax |
43 | cmpl $0x0700, %eax | |
44 | je 1f | |
45 | andl $0x4500, %eax | |
46 | cmpl $0x0100, %eax | |
47 | je 2f | |
48 | fxam | |
49 | fnstsw | |
50 | andl $0x4500, %eax | |
51 | cmpl $0x0100, %eax | |
6d0c4914 | 52 | je 3f |
d705269e UD |
53 | fld %st(1) |
54 | frndint | |
55 | fcomp %st(2) | |
56 | fnstsw | |
57 | sahf | |
e208f556 | 58 | jne 4f |
d38cd08c | 59 | fscale |
3e5f5557 | 60 | fstp %st(1) |
d38cd08c | 61 | ret |
d705269e UD |
62 | |
63 | /* y is -inf */ | |
64 | 1: fxam | |
65 | #ifdef PIC | |
fee732e5 | 66 | LOAD_PIC_REG (cx) |
d705269e UD |
67 | #endif |
68 | fnstsw | |
69 | movl 4(%esp), %edx | |
70 | shrl $5, %eax | |
2827300f UD |
71 | fstp %st |
72 | fstp %st | |
d705269e UD |
73 | andl $0x80000000, %edx |
74 | andl $8, %eax | |
e208f556 | 75 | jnz 4f |
d705269e UD |
76 | shrl $27, %edx |
77 | addl %edx, %eax | |
78 | fldl MOX(zero_nan, %eax, 1) | |
79 | ret | |
80 | ||
81 | /* The result is NaN, but we must not raise an exception. | |
82 | So use a variable. */ | |
83 | 2: fstp %st | |
84 | fstp %st | |
85 | #ifdef PIC | |
fee732e5 | 86 | LOAD_PIC_REG (cx) |
d705269e UD |
87 | #endif |
88 | fldl MO(nan) | |
89 | ret | |
6d0c4914 UD |
90 | |
91 | /* The first parameter is a NaN. Return it. */ | |
92 | 3: fstp %st(1) | |
93 | ret | |
e208f556 UD |
94 | |
95 | /* Return NaN and raise the invalid exception. */ | |
96 | 4: fstp %st | |
97 | fstp %st | |
98 | fldz | |
99 | fdiv %st | |
100 | ret | |
d38cd08c | 101 | END(__ieee754_scalbf) |
0ac5ae23 | 102 | strong_alias (__ieee754_scalbf, __scalbf_finite) |