]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/fpu/e_exp10f.S
196ce8744a0a83800f762547f169d9d22b9561ae
[thirdparty/glibc.git] / sysdeps / i386 / fpu / e_exp10f.S
1 /*
2 * Written by Ulrich Drepper.
3 */
4
5 #include <machine/asm.h>
6 #include <i386-math-asm.h>
7 #include <libm-alias-finite.h>
8
9 DEFINE_FLT_MIN
10
11 #ifdef PIC
12 # define MO(op) op##@GOTOFF(%ecx)
13 #else
14 # define MO(op) op
15 #endif
16
17 .text
18 /* 10^x = 2^(x * log2(10)) */
19 ENTRY(__ieee754_exp10f)
20 #ifdef PIC
21 LOAD_PIC_REG (cx)
22 #endif
23 flds 4(%esp)
24 /* I added the following ugly construct because exp(+-Inf) resulted
25 in NaN. The ugliness results from the bright minds at Intel.
26 For the i686 the code can be written better.
27 -- drepper@cygnus.com. */
28 fxam /* Is NaN or +-Inf? */
29 fstsw %ax
30 movb $0x45, %dh
31 andb %ah, %dh
32 cmpb $0x05, %dh
33 je 1f /* Is +-Inf, jump. */
34 fldl2t
35 fmulp /* x * log2(10) */
36 fld %st
37 frndint /* int(x * log2(10)) */
38 fsubr %st,%st(1) /* fract(x * log2(10)) */
39 fxch
40 f2xm1 /* 2^(fract(x * log2(10))) - 1 */
41 fld1
42 faddp /* 2^(fract(x * log2(10))) */
43 fscale /* e^x */
44 fstp %st(1)
45 FLT_NARROW_EVAL_UFLOW_NONNEG_NAN
46 ret
47
48 1: testl $0x200, %eax /* Test sign. */
49 jz 2f /* If positive, jump. */
50 fstp %st
51 fldz /* Set result to 0. */
52 2: ret
53 END (__ieee754_exp10f)
54 libm_alias_finite (__ieee754_exp10f, __exp10f)