1994-02-11 21:20:17 +03:00
|
|
|
/*
|
1995-04-29 02:43:31 +04:00
|
|
|
* Written by J.T. Conklin <jtc@netbsd.org>.
|
|
|
|
* Public domain.
|
1994-02-11 21:20:17 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <machine/asm.h>
|
|
|
|
|
1996-07-03 21:31:28 +04:00
|
|
|
RCSID("$NetBSD: e_exp.S,v 1.7 1996/07/03 17:31:28 jtc Exp $")
|
1994-03-12 04:30:22 +03:00
|
|
|
|
1994-02-11 21:20:17 +03:00
|
|
|
/* e^x = 2^(x * log2(e)) */
|
|
|
|
ENTRY(__ieee754_exp)
|
1996-07-03 21:27:34 +04:00
|
|
|
pushl %ebp
|
|
|
|
movl %esp,%ebp
|
|
|
|
subl $8,%esp
|
|
|
|
|
|
|
|
fstcw -12(%ebp) /* store fpu control word */
|
|
|
|
movw -12(%ebp),%dx
|
|
|
|
orw $0x0180,%dx
|
|
|
|
movw %dx,-16(%ebp)
|
|
|
|
fldcw -16(%ebp) /* load modfied control word */
|
|
|
|
|
|
|
|
fldl 8(%ebp)
|
1994-02-11 21:20:17 +03:00
|
|
|
fldl2e
|
|
|
|
fmulp /* x * log2(e) */
|
|
|
|
fstl %st(1)
|
|
|
|
frndint /* int(x * log2(e)) */
|
1996-07-03 21:31:28 +04:00
|
|
|
fxch %st(1)
|
|
|
|
fsub %st(1),%st /* fract(x * log2(e)) */
|
1994-02-11 21:20:17 +03:00
|
|
|
f2xm1 /* 2^(fract(x * log2(e))) - 1 */
|
|
|
|
fld1
|
|
|
|
faddp /* 2^(fract(x * log2(e))) */
|
|
|
|
fscale /* e^x */
|
1996-06-25 06:07:09 +04:00
|
|
|
fstpl %st(1)
|
1996-07-03 21:27:34 +04:00
|
|
|
|
|
|
|
fldcw -12(%ebp) /* restore original control word */
|
|
|
|
|
|
|
|
leave
|
1994-02-11 21:20:17 +03:00
|
|
|
ret
|