s_floor.S revision 1.6
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.6SfvdlRCSID("$NetBSD: s_floor.S,v 1.6 2001/06/19 17:49:36 fvdl Exp $")
91.2Sjtc
101.1SjtcENTRY(floor)
111.5Sfvdl#ifdef __i386__
121.1Sjtc	pushl	%ebp
131.1Sjtc	movl	%esp,%ebp
141.1Sjtc	subl	$8,%esp
151.1Sjtc
161.1Sjtc	fstcw	-12(%ebp)		/* store fpu control word */
171.1Sjtc	movw	-12(%ebp),%dx
181.1Sjtc	orw	$0x0400,%dx		/* round towards -oo */
191.1Sjtc	andw	$0xf7ff,%dx
201.1Sjtc	movw	%dx,-16(%ebp)
211.1Sjtc	fldcw	-16(%ebp)		/* load modfied control word */
221.1Sjtc
231.1Sjtc	fldl	8(%ebp);		/* round */
241.1Sjtc	frndint
251.1Sjtc
261.1Sjtc	fldcw	-12(%ebp)		/* restore original control word */
271.1Sjtc
281.1Sjtc	leave
291.5Sfvdl#else
301.5Sfvdl	movsd	%xmm0, -8(%rsp)
311.5Sfvdl	fstcw	-12(%rsp)
321.6Sfvdl	movw	-12(%rsp),%dx
331.5Sfvdl	orw	$0x0400,%dx
341.5Sfvdl	andw	$0xf7ff,%dx
351.5Sfvdl	movw	%dx,-16(%rsp)
361.5Sfvdl	fldcw	-16(%rsp)
371.5Sfvdl	fldl	-8(%rsp)
381.5Sfvdl	frndint
391.5Sfvdl	fldcw	-12(%rsp)
401.5Sfvdl	fstpl	-8(%rsp)
411.5Sfvdl	movsd	-8(%rsp),%xmm0
421.5Sfvdl#endif
431.1Sjtc	ret
44