master
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#include <_mingw_mac.h>
7
8 .file "exp2l.S"
9 .text
10#ifdef __x86_64__
11 .align 8
12#else
13 .align 4
14#endif
15.globl __MINGW_USYMBOL(exp2l)
16 .def __MINGW_USYMBOL(exp2l); .scl 2; .type 32; .endef
17__MINGW_USYMBOL(exp2l):
18#ifdef __x86_64__
19 fldt (%rdx)
20 fxam /* Is NaN or +-Inf? */
21 fstsw %ax
22 movb $0x45, %dh
23 andb %ah, %dh
24 cmpb $0x05, %dh
25 je 1f /* Is +-Inf, jump. */
26 fld %st
27 subq $8, %rsp /* int(x) */
28 fnstcw 4(%rsp)
29 movzwl 4(%rsp), %eax
30 orb $12, %ah
31 movw %ax, (%rsp)
32 fldcw (%rsp)
33 frndint
34 fldcw 4(%rsp)
35 addq $8, %rsp
36 fsubr %st,%st(1) /* fract(x) */
37 fxch
38 f2xm1 /* 2^(fract(x)) - 1 */
39 fld1
40 faddp /* 2^(fract(x)) */
41 fscale /* e^x */
42 fstp %st(1)
43 movq %rcx,%rax
44 movq $0,8(%rcx)
45 fstpt (%rcx)
46 ret
47
481: testl $0x200, %eax /* Test sign. */
49 jz 2f /* If positive, jump. */
50 fstp %st
51 fldz /* Set result to 0. */
522: movq %rcx,%rax
53 movq $0,8(%rcx)
54 fstpt (%rcx)
55 ret
56#else
57 fldt 4(%esp)
58/* I added the following ugly construct because exp(+-Inf) resulted
59 in NaN. The ugliness results from the bright minds at Intel.
60 For the i686 the code can be written better.
61 -- drepper@cygnus.com. */
62 fxam /* Is NaN or +-Inf? */
63 fstsw %ax
64 movb $0x45, %dh
65 andb %ah, %dh
66 cmpb $0x05, %dh
67 je 1f /* Is +-Inf, jump. */
68 fld %st
69 subl $8, %esp /* int(x) */
70 fnstcw 4(%esp)
71 movzwl 4(%esp), %eax
72 orb $12, %ah
73 movw %ax, (%esp)
74 fldcw (%esp)
75 frndint
76 fldcw 4(%esp)
77 addl $8, %esp
78 fsubr %st,%st(1) /* fract(x) */
79 fxch
80 f2xm1 /* 2^(fract(x)) - 1 */
81 fld1
82 faddp /* 2^(fract(x)) */
83 fscale /* e^x */
84 fstp %st(1)
85 ret
86
871: testl $0x200, %eax /* Test sign. */
88 jz 2f /* If positive, jump. */
89 fstp %st
90 fldz /* Set result to 0. */
912: ret
92#endif