xref: /netbsd/lib/libm/arch/i387/s_ceil.S (revision bf9ec67e)
1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 */
5
6#include <machine/asm.h>
7
8#include "abi.h"
9
10RCSID("$NetBSD: s_ceil.S,v 1.6 2002/03/26 15:17:37 fvdl Exp $")
11
12ENTRY(ceil)
13#ifdef __i386__
14	pushl	%ebp
15	movl	%esp,%ebp
16	subl	$8,%esp
17
18	fstcw	-4(%ebp)		/* store fpu control word */
19	movw	-4(%ebp),%dx
20	orw	$0x0800,%dx		/* round towards +oo */
21	andw	$0xfbff,%dx
22	movw	%dx,-8(%ebp)
23	fldcw	-8(%ebp)		/* load modfied control word */
24
25	fldl	8(%ebp);		/* round */
26	frndint
27
28	fldcw	-4(%ebp)		/* restore original control word */
29
30	leave
31#else
32	fstcw	-12(%rsp)
33	movw	-12(%rsp),%dx
34	orw	$0x0800,%dx
35	andw	$0xfbff,%dx
36	movw	%dx,-16(%rsp)
37	fldcw	-16(%rsp)
38	movsd	%xmm0,-8(%rsp)
39	fldl	-8(%rsp)
40	frndint
41	fldcw	-12(%rsp)
42	fstpl	-8(%rsp)
43	movsd	-8(%rsp),%xmm0
44#endif
45	ret
46