s_ceil.S revision 1.5
11.1Sjtc/*
21.3Sjtc * Written by J.T. Conklin <jtc@netbsd.org>.
31.3Sjtc * Public domain.
41.1Sjtc */
51.1Sjtc
61.1Sjtc#include <machine/asm.h>
71.1Sjtc
81.5Sfvdl#include "abi.h"
91.5Sfvdl
101.5SfvdlRCSID("$NetBSD: s_ceil.S,v 1.5 2001/06/19 00:26:30 fvdl Exp $")
111.2Sjtc
121.1SjtcENTRY(ceil)
131.5Sfvdl#ifdef __i386__
141.1Sjtc	pushl	%ebp
151.1Sjtc	movl	%esp,%ebp
161.1Sjtc	subl	$8,%esp
171.1Sjtc
181.1Sjtc	fstcw	-12(%ebp)		/* store fpu control word */
191.1Sjtc	movw	-12(%ebp),%dx
201.1Sjtc	orw	$0x0800,%dx		/* round towards +oo */
211.1Sjtc	andw	$0xfbff,%dx
221.1Sjtc	movw	%dx,-16(%ebp)
231.1Sjtc	fldcw	-16(%ebp)		/* load modfied control word */
241.1Sjtc
251.1Sjtc	fldl	8(%ebp);		/* round */
261.1Sjtc	frndint
271.1Sjtc
281.1Sjtc	fldcw	-12(%ebp)		/* restore original control word */
291.1Sjtc
301.1Sjtc	leave
311.5Sfvdl#else
321.5Sfvdl	fstcw	-12(%rsp)
331.5Sfvdl	movw	-12(%rsp),%dx
341.5Sfvdl	orw	$0x0800,%dx
351.5Sfvdl	andw	$0xfbff,%dx
361.5Sfvdl	movw	%dx,-16(%rsp)
371.5Sfvdl	fldcw	-16(%rsp)
381.5Sfvdl	movsd	%xmm0,-8(%rsp)
391.5Sfvdl	fldl	-8(%rsp)
401.5Sfvdl	frndint
411.5Sfvdl	fldcw	-12(%rsp)
421.5Sfvdl	fstpl	-8(%rsp)
431.5Sfvdl	movsd	-8(%rsp),%xmm0
441.5Sfvdl#endif
451.1Sjtc	ret
46