xref: /freebsd/lib/msun/i387/s_trunc.S (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1/*
2 * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
3 * Public domain.
4 */
5
6#include <machine/asm.h>
7ENTRY(trunc)
8	pushl	%ebp
9	movl	%esp,%ebp
10	subl	$8,%esp
11
12	fstcw	-4(%ebp)		/* store fpu control word */
13	movw	-4(%ebp),%dx
14	orw	$0x0c00,%dx		/* round towards -oo */
15	movw	%dx,-8(%ebp)
16	fldcw	-8(%ebp)		/* load modified control word */
17
18	fldl	8(%ebp)			/* round */
19	frndint
20
21	fldcw	-4(%ebp)		/* restore original control word */
22
23	leave
24	ret
25END(trunc)
26
27	.section .note.GNU-stack,"",%progbits
28