xref: /freebsd/lib/msun/i387/s_floor.S (revision 9235ed71993ec615fd4675e2b0e37afc1c346f48)
13a8617a8SJordan K. Hubbard/*
23a8617a8SJordan K. Hubbard * Copyright (c) 1993,94 Winning Strategies, Inc.
33a8617a8SJordan K. Hubbard * All rights reserved.
43a8617a8SJordan K. Hubbard *
53a8617a8SJordan K. Hubbard * Redistribution and use in source and binary forms, with or without
63a8617a8SJordan K. Hubbard * modification, are permitted provided that the following conditions
73a8617a8SJordan K. Hubbard * are met:
83a8617a8SJordan K. Hubbard * 1. Redistributions of source code must retain the above copyright
93a8617a8SJordan K. Hubbard *    notice, this list of conditions and the following disclaimer.
103a8617a8SJordan K. Hubbard * 2. Redistributions in binary form must reproduce the above copyright
113a8617a8SJordan K. Hubbard *    notice, this list of conditions and the following disclaimer in the
123a8617a8SJordan K. Hubbard *    documentation and/or other materials provided with the distribution.
133a8617a8SJordan K. Hubbard * 3. All advertising materials mentioning features or use of this software
143a8617a8SJordan K. Hubbard *    must display the following acknowledgement:
153a8617a8SJordan K. Hubbard *      This product includes software developed by Winning Strategies, Inc.
163a8617a8SJordan K. Hubbard * 4. The name of the author may not be used to endorse or promote products
173a8617a8SJordan K. Hubbard *    derived from this software without specific prior written permission.
183a8617a8SJordan K. Hubbard *
193a8617a8SJordan K. Hubbard * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
203a8617a8SJordan K. Hubbard * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
213a8617a8SJordan K. Hubbard * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
223a8617a8SJordan K. Hubbard * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
233a8617a8SJordan K. Hubbard * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
243a8617a8SJordan K. Hubbard * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
253a8617a8SJordan K. Hubbard * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
263a8617a8SJordan K. Hubbard * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
273a8617a8SJordan K. Hubbard * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
283a8617a8SJordan K. Hubbard * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
293a8617a8SJordan K. Hubbard */
303a8617a8SJordan K. Hubbard
313a8617a8SJordan K. Hubbard/*
323a8617a8SJordan K. Hubbard * Written by:
333a8617a8SJordan K. Hubbard *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
343a8617a8SJordan K. Hubbard */
353a8617a8SJordan K. Hubbard
366b04d991SBruce Evans#include <machine/asm.h>
373a8617a8SJordan K. Hubbard
387f3dea24SPeter WemmRCSID("$FreeBSD$")
393a8617a8SJordan K. Hubbard
403a8617a8SJordan K. HubbardENTRY(floor)
413a8617a8SJordan K. Hubbard	pushl	%ebp
423a8617a8SJordan K. Hubbard	movl	%esp,%ebp
433a8617a8SJordan K. Hubbard	subl	$8,%esp
443a8617a8SJordan K. Hubbard
45c5dd4039SBruce Evans	fstcw	-4(%ebp)		/* store fpu control word */
46c5dd4039SBruce Evans	movw	-4(%ebp),%dx
473a8617a8SJordan K. Hubbard	orw	$0x0400,%dx		/* round towards -oo */
483a8617a8SJordan K. Hubbard	andw	$0xf7ff,%dx
49c5dd4039SBruce Evans	movw	%dx,-8(%ebp)
50c5dd4039SBruce Evans	fldcw	-8(%ebp)		/* load modfied control word */
513a8617a8SJordan K. Hubbard
523a8617a8SJordan K. Hubbard	fldl	8(%ebp);		/* round */
533a8617a8SJordan K. Hubbard	frndint
543a8617a8SJordan K. Hubbard
55c5dd4039SBruce Evans	fldcw	-4(%ebp)		/* restore original control word */
563a8617a8SJordan K. Hubbard
573a8617a8SJordan K. Hubbard	leave
583a8617a8SJordan K. Hubbard	ret
599235ed71SAttilio RaoEND(floor)
60