about summary refs log tree commit diff
path: root/src/math/x86_64/expl.s
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-03-20 23:29:24 -0400
committerRich Felker <dalias@aerifal.cx>2012-03-20 23:29:24 -0400
commit30df206cb0c66848142898115d301a0d80333d0f (patch)
tree71bc7185b699610ed604a544ad8c508536d8990f /src/math/x86_64/expl.s
parent80949ccdc6656c51292b4260b6e8d7b493ca6c45 (diff)
downloadmusl-30df206cb0c66848142898115d301a0d80333d0f.tar.gz
musl-30df206cb0c66848142898115d301a0d80333d0f.tar.xz
musl-30df206cb0c66848142898115d301a0d80333d0f.zip
x86_64 math asm, long double functions only
this has not been tested heavily, but it's known to at least assemble
and run in basic usage cases. it's nearly identical to the
corresponding i386 code, and thus expected to be just as correct or
just as incorrect.
Diffstat (limited to 'src/math/x86_64/expl.s')
-rw-r--r--src/math/x86_64/expl.s85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/math/x86_64/expl.s b/src/math/x86_64/expl.s
new file mode 100644
index 00000000..64c1c78e
--- /dev/null
+++ b/src/math/x86_64/expl.s
@@ -0,0 +1,85 @@
+.global expm1l
+.type expm1l,@function
+expm1l:
+	fldt 8(%rsp)
+1:	fldl2e
+	fmulp
+	fld1
+	fld %st(1)
+	fabs
+	fucom %st(1)
+	fnstsw %ax
+	fstp %st(0)
+	fstp %st(0)
+	sahf
+	ja 1f
+	f2xm1
+	ret
+1:	push %rax
+	call 1f
+	pop %rax
+	fld1
+	fsubrp
+	ret
+
+.global expl
+.type expl,@function
+expl:
+	fldt 8(%rsp)
+	fldl2e
+	fmulp
+	jmp 1f
+
+.global exp2l
+.type exp2l,@function
+exp2l:
+	fldt 8(%rsp)
+1:	mov $0x467ff000,%eax
+	mov %eax,-16(%rsp)
+	mov $0x80000000,%eax
+	mov %eax,-20(%rsp)
+	xor %eax,%eax
+	mov %eax,-24(%rsp)
+	flds -16(%rsp)
+	fld %st(1)
+	fabs
+	fucom %st(1)
+	fnstsw
+	fstp %st(0)
+	fstp %st(0)
+	sahf
+	ja 2f
+	fld %st(0)
+	fistpl -16(%rsp)
+	fildl -16(%rsp)
+	fxch %st(1)
+	fsub %st(1)
+	mov $0x3fff,%eax
+	add %eax,-16(%rsp)
+	f2xm1
+	fld1
+	faddp
+	fldt -24(%rsp)
+	fmulp
+	fstp %st(1)
+	ret
+
+2:	fld %st(0)
+	fstpt -24(%rsp)
+	mov -15(%rsp),%ah
+	and $0x7f,%ah
+	cmp $0x7f,%ah
+	jne 1f
+	decb -15(%rsp)
+	fstp %st(0)
+	fldt -24(%rsp)
+1:	fld %st(0)
+	frndint
+	fxch %st(1)
+	fsub %st(1)
+	f2xm1
+	fld1
+	faddp
+	fscale
+	fstp %st(1)
+	ret