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 "exp2.S" 9 .text 10#ifdef __x86_64__ 11 .align 8 12#else 13 .align 4 14#endif 15.globl __MINGW_USYMBOL(exp2) 16 .def __MINGW_USYMBOL(exp2); .scl 2; .type 32; .endef 17__MINGW_USYMBOL(exp2): 18#ifdef __x86_64__ 19 subq $24, %rsp 20 movsd %xmm0,(%rsp) 21 fldl (%rsp) 22 fxam /* Is NaN or +-Inf? */ 23 fstsw %ax 24 movb $0x45, %dh 25 andb %ah, %dh 26 cmpb $0x05, %dh 27 je 1f /* Is +-Inf, jump. */ 28 fld %st 29 subq $8, %rsp /* int(x) */ 30 fnstcw 4(%rsp) 31 movzwl 4(%rsp), %eax 32 orb $12, %ah 33 movw %ax, (%rsp) 34 fldcw (%rsp) 35 frndint 36 fldcw 4(%rsp) 37 addq $8, %rsp 38 fsubr %st,%st(1) /* fract(x) */ 39 fxch 40 f2xm1 /* 2^(fract(x)) - 1 */ 41 fld1 42 faddp /* 2^(fract(x)) */ 43 fscale /* e^x */ 44 fstp %st(1) 45 fstpl (%rsp) 46 movsd (%rsp),%xmm0 47 addq $24, %rsp 48 ret 49 501: testl $0x200, %eax /* Test sign. */ 51 jz 2f /* If positive, jump. */ 52 fstp %st 53 fldz /* Set result to 0. */ 542: fstpl (%rsp) 55 movsd (%rsp),%xmm0 56 addq $24,%rsp 57 ret 58#else 59 fldl 4(%esp) 60/* I added the following ugly construct because exp(+-Inf) resulted 61 in NaN. The ugliness results from the bright minds at Intel. 62 For the i686 the code can be written better. 63 -- drepper@cygnus.com. */ 64 fxam /* Is NaN or +-Inf? */ 65 fstsw %ax 66 movb $0x45, %dh 67 andb %ah, %dh 68 cmpb $0x05, %dh 69 je 1f /* Is +-Inf, jump. */ 70 fld %st 71 subl $8, %esp /* int(x) */ 72 fnstcw 4(%esp) 73 movzwl 4(%esp), %eax 74 orb $12, %ah 75 movw %ax, (%esp) 76 fldcw (%esp) 77 frndint 78 fldcw 4(%esp) 79 addl $8, %esp 80 fsubr %st,%st(1) /* fract(x) */ 81 fxch 82 f2xm1 /* 2^(fract(x)) - 1 */ 83 fld1 84 faddp /* 2^(fract(x)) */ 85 fscale /* e^x */ 86 fstp %st(1) 87 ret 88 891: testl $0x200, %eax /* Test sign. */ 90 jz 2f /* If positive, jump. */ 91 fstp %st 92 fldz /* Set result to 0. */ 932: ret 94#endif 95