Revert "rename amd64 architecture to x86_64"
[dragonfly.git] / lib / libc / amd64 / gen / fpsetround.S
1 /*
2  * Written by Frank van der Linden at Wasabi Systems for NetBSD.
3  * Public domain.
4  *
5  * $NetBSD: fpsetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $
6  * $DragonFly: src/lib/libc/amd64/gen/fpsetround.S,v 1.1 2006/07/27 00:46:57 corecode Exp $
7  */
8
9 #include <machine/asm.h>
10
11 /*
12  * XXX set both the x87 control word and the SSE mxcsr register.
13  * Applications should only set exception and round flags
14  * via the fp*() interface, otherwise the status words
15  * will get our of sync.
16  */ 
17
18
19 #ifdef WEAK_ALIAS
20 WEAK_ALIAS(fpsetround, _fpsetround)
21 ENTRY(_fpsetround)
22 #else
23 ENTRY(fpsetround)
24 #endif
25         fnstcw  -4(%rsp)
26         stmxcsr -8(%rsp)
27
28         andl    $3,%edi
29
30         movl    -4(%rsp),%edx
31         rorl    $10,%edx
32         movl    %edx,%eax
33         andl    $3,%eax
34
35         andl    $~3,%edx
36         orl     %edi,%edx
37         roll    $10,%edx
38         movl    %edx,-4(%rsp)
39
40         movl    -8(%rsp),%edx
41         rorl    $13,%edx
42         andl    $~3,%edx
43         orl     %edi,%edx
44         roll    $13,%edx
45         movl    %edx,-8(%rsp)
46
47         ldmxcsr -8(%rsp)
48         fldcw   -4(%rsp)
49         ret