]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/libm-i387/e_expl.S
update from main archive 961005
[thirdparty/glibc.git] / sysdeps / libm-i387 / e_expl.S
CommitLineData
ee188d55
RM
1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 *
5 * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
6 */
7
8#include <machine/asm.h>
9
10RCSID("$NetBSD: $")
11
12/* e^x = 2^(x * log2l(e)) */
13ENTRY(__ieee754_expl)
14 fldt 4(%esp)
15/* I added the following ugly construct because expl(+-Inf) resulted
16 in NaN. The ugliness results from the bright minds at Intel.
cccda09f 17 For the i686 the code can be written better.
ee188d55
RM
18 -- drepper@cygnus.com. */
19 fxam /* Is NaN or +-Inf? */
20 fstsw %ax
21 sahf
22 jnc .LnoInfNaN /* No, jump. */
23 jp .LisInf /* Is +-Inf, jump. */
24.LnoInfNaN:
25 fldl2e
26 fmulp /* x * log2(e) */
27 fstl %st(1)
28 frndint /* int(x * log2(e)) */
29 fstl %st(2)
30 fsubrp /* fract(x * log2(e)) */
31 f2xm1 /* 2^(fract(x * log2(e))) - 1 */
32 fld1
33 faddp /* 2^(fract(x * log2(e))) */
34 fscale /* e^x */
35 ret
36
37.LisInf:
38 andb $2, %ah /* Test sign. */
39 jz .LpInf /* If positive, jump. */
40 fldz /* Set result to 0. */
41.LpInf: ret
cccda09f 42PSEUDO_END (__ieee754_expl)