2 * Written by J.T. Conklin <jtc@netbsd.org>.
6 #include <machine/asm.h>
9 /* e^x = 2^(x * log2(e)) */
12 /* I added the following ugly construct because exp(+-Inf) resulted
13 in NaN. The ugliness results from the bright minds at Intel.
14 For the i686 the code can be written better.
15 -- drepper@cygnus.com. */
16 fxam /* Is NaN or +-Inf? */
21 je 1f /* Is +-Inf, jump. */
23 fmulp /* x * log2(e) */
25 frndint /* int(x * log2(e)) */
26 fsubr %st,%st(1) /* fract(x * log2(e)) */
28 f2xm1 /* 2^(fract(x * log2(e))) - 1 */
30 faddp /* 2^(fract(x * log2(e))) */
35 1: testl $0x200, %eax /* Test sign. */
36 jz 2f /* If positive, jump. */
38 fldz /* Set result to 0. */
45 fmull 4(%esp) /* x * log2(e) */
47 frndint /* int(x * log2(e)) */
48 fsubr %st,%st(1) /* fract(x * log2(e)) */
50 f2xm1 /* 2^(fract(x * log2(e))) - 1 */
52 faddp /* 2^(fract(x * log2(e))) */