The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Based on code written by J.T. Conklin <jtc@NetBSD.org>. |
| 3 | * Public domain. |
| 4 | */ |
| 5 | |
| 6 | #include <machine/asm.h> |
| 7 | __FBSDID("$FreeBSD: src/lib/msun/i387/s_trunc.S,v 1.1 2005/04/16 21:12:55 das Exp $") |
| 8 | |
| 9 | ENTRY(trunc) |
| 10 | pushl %ebp |
| 11 | movl %esp,%ebp |
| 12 | subl $8,%esp |
| 13 | |
| 14 | fstcw -4(%ebp) /* store fpu control word */ |
| 15 | movw -4(%ebp),%dx |
| 16 | orw $0x0c00,%dx /* round towards -oo */ |
| 17 | movw %dx,-8(%ebp) |
| 18 | fldcw -8(%ebp) /* load modfied control word */ |
| 19 | |
| 20 | fldl 8(%ebp) /* round */ |
| 21 | frndint |
| 22 | |
| 23 | fldcw -4(%ebp) /* restore original control word */ |
| 24 | |
| 25 | leave |
| 26 | ret |