xref: /netbsd-src/lib/libc/arch/i386/gen/fpsetround.S (revision 9fbd88883c38d0c0fbfcbe66d76fe6b0fab3f9de)
1/*	$NetBSD: fpsetround.S,v 1.3 2002/01/13 21:45:43 thorpej Exp $	*/
2
3/*
4 * Written by Charles M. Hannum, Apr 9, 1995
5 * Public domain.
6 */
7
8#include <machine/asm.h>
9
10#ifdef WEAK_ALIAS
11WEAK_ALIAS(fpsetround, _fpsetround)
12ENTRY(_fpsetround)
13#else
14ENTRY(fpsetround)
15#endif
16	subl $4,%esp
17
18	fnstcw (%esp)
19	movl (%esp),%eax
20
21	rorl $10,%eax
22	movl %eax,%edx
23	andl $3,%eax
24
25	subl %eax,%edx
26	movl 8(%esp),%ecx
27	andl $3,%ecx
28	orl %ecx,%edx
29	roll $10,%edx
30	movl %edx,(%esp)
31	fldcw (%esp)
32
33	addl $4,%esp
34	ret
35