update from main archive 961005
[glibc/history.git] / sysdeps / libm-i387 / e_exp.S
blobdad201fb3fdbeb297c69b2fcaaac6f5cf3cff9ab
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Public domain.
4  */
6 #include <machine/asm.h>
8 RCSID("$NetBSD: e_exp.S,v 1.4 1995/05/08 23:47:04 jtc Exp $")
10 /* e^x = 2^(x * log2(e)) */
11 ENTRY(__ieee754_exp)
12         fldl    4(%esp)
13 /* I added the following ugly construct because exp(+-Inf) resulted
14    in NaN.  The ugliness results from the bright minds at Intel.
15    For the i686 the code can be written better.
16    -- drepper@cygnus.com.  */
17         fxam                            /* Is NaN or +-Inf?  */
18         fstsw   %ax
19         sahf
20         jnc     .LnoInfNaN              /* No, jump.   */
21         jp      .LisInf                 /* Is +-Inf, jump.  */
22 .LnoInfNaN:
23         fldl2e
24         fmulp                           /* x * log2(e) */
25         fstl    %st(1)
26         frndint                         /* int(x * log2(e)) */
27         fstl    %st(2)
28         fsubrp                          /* fract(x * log2(e)) */
29         f2xm1                           /* 2^(fract(x * log2(e))) - 1 */
30         fld1
31         faddp                           /* 2^(fract(x * log2(e))) */
32         fscale                          /* e^x */
33         ret
35 .LisInf:
36         andb    $2, %ah                 /* Test sign.  */
37         jz      .LpInf                  /* If positive, jump.  */
38         fldz                            /* Set result to 0.  */
39 .LpInf: ret
40 PSEUDO_END (__ieee754_exp)