fix getaddrinfo regression with AI_ADDRCONFIG on some configurations
[musl.git] / src / math / i386 / exp.s
blobc7aa5b6eaa37a8385ff3998cf5b690884295618d
1 .global expm1f
2 .type expm1f,@function
3 expm1f:
4 flds 4(%esp)
5 mov 4(%esp),%eax
6 add %eax,%eax
7 cmp $0x01000000,%eax
8 jae 1f
9 # subnormal x, return x with underflow
10 fnstsw %ax
11 and $16,%ax
12 jnz 2f
13 fld %st(0)
14 fmul %st(1)
15 fstps 4(%esp)
16 2: ret
18 .global expm1l
19 .type expm1l,@function
20 expm1l:
21 fldt 4(%esp)
22 jmp 1f
24 .global expm1
25 .type expm1,@function
26 expm1:
27 fldl 4(%esp)
28 mov 8(%esp),%eax
29 add %eax,%eax
30 cmp $0x00200000,%eax
31 jae 1f
32 # subnormal x, return x with underflow
33 fnstsw %ax
34 and $16,%ax
35 jnz 2f
36 fsts 4(%esp)
37 2: ret
38 1: fldl2e
39 fmulp
40 mov $0xc2820000,%eax
41 push %eax
42 flds (%esp)
43 pop %eax
44 fucomp %st(1)
45 fnstsw %ax
46 sahf
47 fld1
48 jb 1f
49 # x*log2e < -65, return -1 without underflow
50 fstp %st(1)
51 fchs
52 ret
53 1: fld %st(1)
54 fabs
55 fucom %st(1)
56 fnstsw %ax
57 fstp %st(0)
58 fstp %st(0)
59 sahf
60 ja 1f
61 f2xm1
62 ret
63 1: call 1f
64 fld1
65 fsubrp
66 ret
68 .global exp2f
69 .type exp2f,@function
70 exp2f:
71 flds 4(%esp)
72 jmp 1f
74 .global exp2l
75 .global __exp2l
76 .hidden __exp2l
77 .type exp2l,@function
78 exp2l:
79 __exp2l:
80 fldt 4(%esp)
81 jmp 1f
83 .global expf
84 .type expf,@function
85 expf:
86 flds 4(%esp)
87 jmp 2f
89 .global exp
90 .type exp,@function
91 exp:
92 fldl 4(%esp)
93 2: fldl2e
94 fmulp
95 jmp 1f
97 .global exp2
98 .type exp2,@function
99 exp2:
100 fldl 4(%esp)
101 1: sub $12,%esp
102 fld %st(0)
103 fstpt (%esp)
104 mov 8(%esp),%ax
105 and $0x7fff,%ax
106 cmp $0x3fff+13,%ax
107 jb 4f # |x| < 8192
108 cmp $0x3fff+15,%ax
109 jae 3f # |x| >= 32768
110 fsts (%esp)
111 cmpl $0xc67ff800,(%esp)
112 jb 2f # x > -16382
113 movl $0x5f000000,(%esp)
114 flds (%esp) # 0x1p63
115 fld %st(1)
116 fsub %st(1)
117 faddp
118 fucomp %st(1)
119 fnstsw
120 sahf
121 je 2f # x - 0x1p63 + 0x1p63 == x
122 movl $1,(%esp)
123 flds (%esp) # 0x1p-149
124 fdiv %st(1)
125 fstps (%esp) # raise underflow
126 2: fld1
127 fld %st(1)
128 frndint
129 fxch %st(2)
130 fsub %st(2) # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
131 f2xm1
132 faddp # 2^(x-rint(x))
133 1: fscale
134 fstp %st(1)
135 add $12,%esp
137 3: xor %eax,%eax
138 4: cmp $0x3fff-64,%ax
139 fld1
140 jb 1b # |x| < 0x1p-64
141 fstpt (%esp)
142 fistl 8(%esp)
143 fildl 8(%esp)
144 fsubrp %st(1)
145 addl $0x3fff,8(%esp)
146 f2xm1
147 fld1
148 faddp # 2^(x-rint(x))
149 fldt (%esp) # 2^rint(x)
150 fmulp
151 add $12,%esp