2.9
[glibc/nacl-glibc.git] / sysdeps / i386 / fpu / e_exp10.S
blob6bfcdbb72335677545bff57351363eae78ff27df
1 /*
2  * Written by Ulrich Drepper <drepper@cygnus.com>.
3  */
5 #include <machine/asm.h>
7 /* 10^x = 2^(x * log2(10)) */
8 ENTRY(__ieee754_exp10)
9         fldl    4(%esp)
10 /* I added the following ugly construct because exp(+-Inf) resulted
11    in NaN.  The ugliness results from the bright minds at Intel.
12    For the i686 the code can be written better.
13    -- drepper@cygnus.com.  */
14         fxam                            /* Is NaN or +-Inf?  */
15         fstsw   %ax
16         movb    $0x45, %dh
17         andb    %ah, %dh
18         cmpb    $0x05, %dh
19         je      1f                      /* Is +-Inf, jump.  */
20         fldl2t
21         fmulp                           /* x * log2(10) */
22         fld     %st
23         frndint                         /* int(x * log2(10)) */
24         fsubr   %st,%st(1)              /* fract(x * log2(10)) */
25         fxch
26         f2xm1                           /* 2^(fract(x * log2(10))) - 1 */
27         fld1
28         faddp                           /* 2^(fract(x * log2(10))) */
29         fscale                          /* e^x */
30         fstp    %st(1)
31         ret
33 1:      testl   $0x200, %eax            /* Test sign.  */
34         jz      2f                      /* If positive, jump.  */
35         fstp    %st
36         fldz                            /* Set result to 0.  */
37 2:      ret
38 END (__ieee754_exp10)