summaryrefslogtreecommitdiffstats
path: root/lib/msun/i387/s_trunc.S
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2005-04-16 21:12:55 +0000
committerdas <das@FreeBSD.org>2005-04-16 21:12:55 +0000
commit9c49c2a65a7716bcd9c75a74df1af7695cfad48f (patch)
tree7d175e24cc4583e1a5a8407639639582a10bced5 /lib/msun/i387/s_trunc.S
parenta9fd105354f92d739364a8db4c72a9ebc48e2db7 (diff)
downloadFreeBSD-src-9c49c2a65a7716bcd9c75a74df1af7695cfad48f.zip
FreeBSD-src-9c49c2a65a7716bcd9c75a74df1af7695cfad48f.tar.gz
More optimized math functions.
Diffstat (limited to 'lib/msun/i387/s_trunc.S')
-rw-r--r--lib/msun/i387/s_trunc.S26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/msun/i387/s_trunc.S b/lib/msun/i387/s_trunc.S
new file mode 100644
index 0000000..91926d7
--- /dev/null
+++ b/lib/msun/i387/s_trunc.S
@@ -0,0 +1,26 @@
+/*
+ * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$")
+
+ENTRY(trunc)
+ pushl %ebp
+ movl %esp,%ebp
+ subl $8,%esp
+
+ fstcw -4(%ebp) /* store fpu control word */
+ movw -4(%ebp),%dx
+ orw $0x0c00,%dx /* round towards -oo */
+ movw %dx,-8(%ebp)
+ fldcw -8(%ebp) /* load modfied control word */
+
+ fldl 8(%ebp) /* round */
+ frndint
+
+ fldcw -4(%ebp) /* restore original control word */
+
+ leave
+ ret
OpenPOWER on IntegriCloud