elf.h: add ELFCOMPRESS_ZSTD
[musl] / src / math / i386 / exp_ld.s
1 .global expm1l
2 .type expm1l,@function
3 expm1l:
4         fldt 4(%esp)
5         fldl2e
6         fmulp
7         mov $0xc2820000,%eax
8         push %eax
9         flds (%esp)
10         pop %eax
11         fucomp %st(1)
12         fnstsw %ax
13         sahf
14         fld1
15         jb 1f
16                 # x*log2e < -65, return -1 without underflow
17         fstp %st(1)
18         fchs
19         ret
20 1:      fld %st(1)
21         fabs
22         fucom %st(1)
23         fnstsw %ax
24         fstp %st(0)
25         fstp %st(0)
26         sahf
27         ja 1f
28         f2xm1
29         ret
30 1:      call 1f
31         fld1
32         fsubrp
33         ret
34
35 .global exp2l
36 .global __exp2l
37 .hidden __exp2l
38 .type exp2l,@function
39 exp2l:
40 __exp2l:
41         fldt 4(%esp)
42 1:      sub $12,%esp
43         fld %st(0)
44         fstpt (%esp)
45         mov 8(%esp),%ax
46         and $0x7fff,%ax
47         cmp $0x3fff+13,%ax
48         jb 4f             # |x| < 8192
49         cmp $0x3fff+15,%ax
50         jae 3f            # |x| >= 32768
51         fsts (%esp)
52         cmpl $0xc67ff800,(%esp)
53         jb 2f             # x > -16382
54         movl $0x5f000000,(%esp)
55         flds (%esp)       # 0x1p63
56         fld %st(1)
57         fsub %st(1)
58         faddp
59         fucomp %st(1)
60         fnstsw
61         sahf
62         je 2f             # x - 0x1p63 + 0x1p63 == x
63         movl $1,(%esp)
64         flds (%esp)       # 0x1p-149
65         fdiv %st(1)
66         fstps (%esp)      # raise underflow
67 2:      fld1
68         fld %st(1)
69         frndint
70         fxch %st(2)
71         fsub %st(2)       # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
72         f2xm1
73         faddp             # 2^(x-rint(x))
74 1:      fscale
75         fstp %st(1)
76         add $12,%esp
77         ret
78 3:      xor %eax,%eax
79 4:      cmp $0x3fff-64,%ax
80         fld1
81         jb 1b             # |x| < 0x1p-64
82         fstpt (%esp)
83         fistl 8(%esp)
84         fildl 8(%esp)
85         fsubrp %st(1)
86         addl $0x3fff,8(%esp)
87         f2xm1
88         fld1
89         faddp             # 2^(x-rint(x))
90         fldt (%esp)       # 2^rint(x)
91         fmulp
92         add $12,%esp
93         ret