summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-07-27 10:43:56 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-07-27 10:43:56 +0000
commit5507d8e1c590b85bc9d7a51585295d6a2284f9fd (patch)
tree81a6843b7b29608a781417639e9644fc6f8a3b14
parentb9f23ea56ec01d4abd015565bbd30e818243ff76 (diff)
fix from bde; Clean up the FP stack before returning. The i387 exp()
leaked an FP register on its first call. Subsequent calls reused the register so the leak didn't accumulate. + some netbsd improvements after that.
-rw-r--r--lib/libm/arch/i387/e_exp.S23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/libm/arch/i387/e_exp.S b/lib/libm/arch/i387/e_exp.S
index 8c41ce09dd5..87db828e639 100644
--- a/lib/libm/arch/i387/e_exp.S
+++ b/lib/libm/arch/i387/e_exp.S
@@ -5,19 +5,34 @@
#include <machine/asm.h>
-RCSID("$NetBSD: e_exp.S,v 1.4 1995/05/08 23:47:04 jtc Exp $")
+RCSID("$NetBSD: e_exp.S,v 1.4.6.1 1996/07/03 19:27:36 jtc Exp $")
/* e^x = 2^(x * log2(e)) */
ENTRY(__ieee754_exp)
- fldl 4(%esp)
+ 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)) */
- fstl %st(2)
- fsubrp /* fract(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