s_ceil.S revision 1.8
11.1Sjtc/*
21.7Ssalo * 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.8SjoergRCSID("$NetBSD: s_ceil.S,v 1.8 2011/06/18 21:24:51 joerg 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.6Sfvdl	fstcw	-4(%ebp)		/* store fpu control word */
191.6Sfvdl	movw	-4(%ebp),%dx
201.1Sjtc	orw	$0x0800,%dx		/* round towards +oo */
211.1Sjtc	andw	$0xfbff,%dx
221.6Sfvdl	movw	%dx,-8(%ebp)
231.6Sfvdl	fldcw	-8(%ebp)		/* load modfied control word */
241.1Sjtc
251.8Sjoerg	fldl	8(%ebp)			/* round */
261.1Sjtc	frndint
271.1Sjtc
281.6Sfvdl	fldcw	-4(%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