about summary refs log tree commit diff
path: root/src/math/i386/exp.s
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-03-18 23:17:28 -0400
committerRich Felker <dalias@aerifal.cx>2012-03-18 23:17:28 -0400
commitaa1b4dff45788f8205e32ea01da243fe09568aa8 (patch)
tree2fb4aa7cf4e3b9ead26ac895d4a22794144f59dd /src/math/i386/exp.s
parent37eb14dd2b92c51404fa54f56b6dfcd487ab5cbb (diff)
downloadmusl-aa1b4dff45788f8205e32ea01da243fe09568aa8.tar.gz
musl-aa1b4dff45788f8205e32ea01da243fe09568aa8.tar.xz
musl-aa1b4dff45788f8205e32ea01da243fe09568aa8.zip
fix broken exponential asm
infinities were getting converted into nans. the new code simply tests
for infinity and replaces it with a large magnitude value of the same
sign.

also, the fcomi instruction is apparently not part of the i387
instruction set, so avoid using it.
Diffstat (limited to 'src/math/i386/exp.s')
-rw-r--r--src/math/i386/exp.s9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/math/i386/exp.s b/src/math/i386/exp.s
index 18f6cd67..f4769d59 100644
--- a/src/math/i386/exp.s
+++ b/src/math/i386/exp.s
@@ -34,6 +34,15 @@ exp:
 .type exp2,@function
 exp2:
 	fldl 4(%esp)
+1:	fxam
+	fnstsw %ax
+	sahf
+	jnp 1f
+	jnc 1f
+	fstps 4(%esp)
+	mov $0xfe,%al
+	and %al,7(%esp)
+	flds 4(%esp)
 1:	fld %st(0)
 	frndint
 	fxch %st(1)