2 * Written by J.T. Conklin <jtc@netbsd.org>.
4 * Adapted for float type by Ulrich Drepper <drepper@cygnus.com>.
7 #include <machine/asm.h>
11 /* e^x = 2^(x * log2(e)) */
14 /* I added the following ugly construct because exp(+-Inf) resulted
15 in NaN. The ugliness results from the bright minds at Intel.
16 For the i686 the code can be written better.
17 -- drepper@cygnus.com. */
18 fxam /* Is NaN or +-Inf? */
23 je 1f /* Is +-Inf, jump. */
25 fmulp /* x * log2(e) */
27 frndint /* int(x * log2(e)) */
28 fsubr %st,%st(1) /* fract(x * log2(e)) */
30 f2xm1 /* 2^(fract(x * log2(e))) - 1 */
32 faddp /* 2^(fract(x * log2(e))) */
37 1: testl $0x200, %eax /* Test sign. */
38 jz 2f /* If positive, jump. */
40 fldz /* Set result to 0. */