flt_rounds.S revision 1.4 1 1.3 christos /* $NetBSD: flt_rounds.S,v 1.4 2011/09/29 22:45:20 christos Exp $ */
2 1.1 fvdl
3 1.4 christos #include <machine/asm.h>
4 1.4 christos
5 1.1 fvdl /*
6 1.4 christos * 00 0 round to zero
7 1.4 christos * 01 1 round to nearest
8 1.4 christos * 10 2 round to positive infinity
9 1.4 christos * 11 3 round to negative infinity
10 1.1 fvdl */
11 1.1 fvdl .text
12 1.1 fvdl _ALIGN_TEXT
13 1.1 fvdl ENTRY(__flt_rounds)
14 1.4 christos fnstcw -4(%rsp)
15 1.4 christos movl -4(%rsp), %ecx
16 1.4 christos shrl $9, %ecx
17 1.4 christos andl $6, %ecx
18 1.4 christos xorl $1, %eax /* map 0,1,2,3 -> 1,0,3,2 */
19 1.4 christos andl $3, %eax
20 1.1 fvdl ret
21