NetBSD/lib/libm/arch/i387/e_exp.S

39 lines
753 B
ArmAsm
Raw Normal View History

1994-02-11 21:20:17 +03: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-02-11 21:20:17 +03:00
/* e^x = 2^(x * log2(e)) */
ENTRY(__ieee754_exp)
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 */
fstpl %st(1)
fldcw -12(%ebp) /* restore original control word */
leave
1994-02-11 21:20:17 +03:00
ret