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