1/* $OpenBSD: fpsetround.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */ 2/* $NetBSD: fpsetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */ 3 4/* 5 * Written by Frank van der Linden at Wasabi Systems for NetBSD. 6 * Public domain. 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 20WEAK_ALIAS(fpsetround, _fpsetround) 21ENTRY(_fpsetround) 22#else 23ENTRY(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 50