fpsetround.S revision 1.5 1 /* $NetBSD: fpsetround.S,v 1.5 2014/05/22 15:01:56 uebayasi Exp $ */
2
3 /*
4 * Written by Frank van der Linden at Wasabi Systems for NetBSD.
5 * Public domain.
6 */
7
8 #include <machine/asm.h>
9
10 /*
11 * XXX set both the x87 control word and the SSE mxcsr register.
12 * Applications should only set exception and round flags
13 * via the fp*() interface, otherwise the status words
14 * will get our of sync.
15 */
16
17
18 #ifdef WEAK_ALIAS
19 WEAK_ALIAS(fpsetround, _fpsetround)
20 ENTRY(_fpsetround)
21 #else
22 ENTRY(fpsetround)
23 #endif
24
25 fnstcw -4(%rsp)
26 movl -4(%rsp), %edx
27 movl %edx, %eax
28 andl $0x00000c00, %eax
29 andl $0xfffff3ff, %edx
30 orl %edi, %edx
31 movl %edx, -4(%rsp)
32 fldcw -4(%rsp)
33
34 stmxcsr -4(%rsp)
35 movl -4(%rsp), %edx
36 andl $0xffff9fff, %edx
37 sall $3, %edi
38 orl %edi,%edx
39 movl %edx,-4(%rsp)
40 ldmxcsr -4(%rsp)
41
42 ret
43 #ifdef WEAK_ALIAS
44 END(_fpsetround)
45 #else
46 END(fpsetround)
47 #endif
48