diff options
author | das <das@FreeBSD.org> | 2005-04-16 21:12:55 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2005-04-16 21:12:55 +0000 |
commit | 9c49c2a65a7716bcd9c75a74df1af7695cfad48f (patch) | |
tree | 7d175e24cc4583e1a5a8407639639582a10bced5 /lib/msun/i387/s_trunc.S | |
parent | a9fd105354f92d739364a8db4c72a9ebc48e2db7 (diff) | |
download | FreeBSD-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.S | 26 |
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 |