summaryrefslogtreecommitdiff
path: root/lib/libm/arch/amd64/s_floorf.S
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2004-02-08 18:03:51 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2004-02-08 18:03:51 +0000
commitf9d4dbafe850675850558e2c8597b232b8be0e88 (patch)
treec7db9cbea87fe13a78bd1aa5a591a820d663b9dc /lib/libm/arch/amd64/s_floorf.S
parentd1b83f8bb6e1bc54b2b16eace08563acb5e968a0 (diff)
add libm parts for amd64; much from netbsd, integration by mickey.
Instead of mixing the i387 & xmm register components, we decide to explicitly seperate them. libm is already confusing enough as it is, thank you very much
Diffstat (limited to 'lib/libm/arch/amd64/s_floorf.S')
-rw-r--r--lib/libm/arch/amd64/s_floorf.S43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/libm/arch/amd64/s_floorf.S b/lib/libm/arch/amd64/s_floorf.S
new file mode 100644
index 00000000000..6a9dab0ca7c
--- /dev/null
+++ b/lib/libm/arch/amd64/s_floorf.S
@@ -0,0 +1,43 @@
+/*
+ * Written by J.T. Conklin <jtc@NetBSD.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_floorf.S,v 1.6 2003/07/26 19:25:02 salo Exp $")
+
+ENTRY(floorf)
+#ifdef __i386__
+ pushl %ebp
+ movl %esp,%ebp
+ subl $8,%esp
+
+ fstcw -4(%ebp) /* store fpu control word */
+ movw -4(%ebp),%dx
+ orw $0x0400,%dx /* round towards -oo */
+ andw $0xf7ff,%dx
+ movw %dx,-8(%ebp)
+ fldcw -8(%ebp) /* load modfied control word */
+
+ flds 8(%ebp); /* round */
+ frndint
+
+ fldcw -4(%ebp) /* restore original control word */
+
+ leave
+#else
+ movss %xmm0, -4(%rsp)
+ fstcw -8(%rsp)
+ movw -8(%rsp),%dx
+ orw $0x0400,%dx
+ andw $0xf7ff,%dx
+ movw %dx,-12(%rsp)
+ fldcw -12(%rsp)
+ fldl -4(%rsp)
+ frndint
+ fldcw -8(%rsp)
+ fstpl -4(%rsp)
+ movss -4(%rsp),%xmm0
+#endif
+ ret