xref: /freebsd/lib/msun/i387/s_truncl.S (revision 1d386b48a555f61cb7325543adbbb5c3f3407a66)
1a4ca7ca8SDavid Schultz/*
2a4ca7ca8SDavid Schultz * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
3a4ca7ca8SDavid Schultz * Public domain.
4a4ca7ca8SDavid Schultz */
5a4ca7ca8SDavid Schultz
6a4ca7ca8SDavid Schultz#include <machine/asm.h>
7a4ca7ca8SDavid SchultzENTRY(truncl)
8a4ca7ca8SDavid Schultz	pushl	%ebp
9a4ca7ca8SDavid Schultz	movl	%esp,%ebp
10a4ca7ca8SDavid Schultz	subl	$8,%esp
11a4ca7ca8SDavid Schultz
12a4ca7ca8SDavid Schultz	fstcw	-4(%ebp)		/* store fpu control word */
13a4ca7ca8SDavid Schultz	movw	-4(%ebp),%dx
14a4ca7ca8SDavid Schultz	orw	$0x0c00,%dx		/* round towards -oo */
15a4ca7ca8SDavid Schultz	movw	%dx,-8(%ebp)
16*a52f4499SGordon Bergling	fldcw	-8(%ebp)		/* load modified control word */
17a4ca7ca8SDavid Schultz
18a4ca7ca8SDavid Schultz	fldt	8(%ebp)			/* round */
19a4ca7ca8SDavid Schultz	frndint
20a4ca7ca8SDavid Schultz
21a4ca7ca8SDavid Schultz	fldcw	-4(%ebp)		/* restore original control word */
22a4ca7ca8SDavid Schultz
23a4ca7ca8SDavid Schultz	leave
24a4ca7ca8SDavid Schultz	ret
259235ed71SAttilio RaoEND(truncl)
268997563cSKonstantin Belousov
278997563cSKonstantin Belousov	.section .note.GNU-stack,"",%progbits
28