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

39 lines
753 B
ArmAsm

/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
RCSID("$NetBSD: e_exp.S,v 1.7 1996/07/03 17:31:28 jtc Exp $")
/* 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)
fldl2e
fmulp /* x * log2(e) */
fstl %st(1)
frndint /* int(x * log2(e)) */
fxch %st(1)
fsub %st(1),%st /* fract(x * log2(e)) */
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
ret