Home | History | Annotate | Line # | Download | only in gen
fpsetround.S revision 1.3
      1 /*	$NetBSD: fpsetround.S,v 1.3 2002/06/12 19:17:22 fvdl 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 	fnstcw	-4(%rsp)
     25 	stmxcsr	-8(%rsp)
     26 
     27 	andl	$3,%edi
     28 
     29 	movl	-4(%rsp),%edx
     30 	rorl	$10,%edx
     31 	movl	%edx,%eax
     32 	andl	$3,%eax
     33 
     34 	andl	$~3,%edx
     35 	orl	%edi,%edx
     36 	roll	$10,%edx
     37 	movl	%edx,-4(%rsp)
     38 
     39 	movl	-8(%rsp),%edx
     40 	rorl	$13,%edx
     41 	andl	$~3,%edx
     42 	orl	%edi,%edx
     43 	roll	$13,%edx
     44 	movl	%edx,-8(%rsp)
     45 
     46 	ldmxcsr	-8(%rsp)
     47 	fldcw	-4(%rsp)
     48 	ret
     49