xref: /netbsd-src/lib/libm/arch/m68k/s_ceil.S (revision ef132276252605d2cd03b45591d69ebe3d8937e5)
1*ef132276Sisaki/*	$NetBSD: s_ceil.S,v 1.9 2014/08/10 13:30:43 isaki Exp $	*/
2bebf6897Sthorpej
3c78325aeSis/*-
4c78325aeSis * Copyright (c) 1990 The Regents of the University of California.
5c78325aeSis * All rights reserved.
6c78325aeSis *
7c78325aeSis * This code is derived from software contributed to Berkeley by
8c78325aeSis * the Systems Programming Group of the University of Utah Computer
9c78325aeSis * Science Department.
10c78325aeSis *
11c78325aeSis * Redistribution and use in source and binary forms, with or without
12c78325aeSis * modification, are permitted provided that the following conditions
13c78325aeSis * are met:
14c78325aeSis * 1. Redistributions of source code must retain the above copyright
15c78325aeSis *    notice, this list of conditions and the following disclaimer.
16c78325aeSis * 2. Redistributions in binary form must reproduce the above copyright
17c78325aeSis *    notice, this list of conditions and the following disclaimer in the
18c78325aeSis *    documentation and/or other materials provided with the distribution.
19eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors
20c78325aeSis *    may be used to endorse or promote products derived from this software
21c78325aeSis *    without specific prior written permission.
22c78325aeSis *
23c78325aeSis * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24c78325aeSis * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25c78325aeSis * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26c78325aeSis * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27c78325aeSis * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28c78325aeSis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29c78325aeSis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30c78325aeSis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31c78325aeSis * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32c78325aeSis * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33c78325aeSis * SUCH DAMAGE.
34c78325aeSis */
35c78325aeSis
36c78325aeSis#include <machine/asm.h>
37c78325aeSis
38c78325aeSis;_sccsid:
39c78325aeSis;.asciz	"from: @(#)floor.s	5.1 (Berkeley) 5/17/90"
40c78325aeSis
41*ef132276SisakiRCSID("$NetBSD: s_ceil.S,v 1.9 2014/08/10 13:30:43 isaki Exp $")
42c78325aeSis
43c78325aeSis| ceil(x)
44c78325aeSisENTRY(ceil)
45bebf6897Sthorpej	fmovel	%fpcr,%d0	| save old FPCR
46bebf6897Sthorpej	fmoved	%sp@(4),%fp0	| get argument
47c78325aeSis	fbun	Lret		| if NaN, return NaN
48914e175cSisaki	fmovel	#0x30,%fpcr	| round to +inf
49*ef132276Sisaki	fintx	%fp0		| truncate
50bebf6897Sthorpej	fmovel	%d0,%fpcr	| restore old FPCR
51c78325aeSisLret:
52c78325aeSis#ifndef __SVR4_ABI__
53bebf6897Sthorpej	fmoved	%fp0,%sp@-
54bebf6897Sthorpej	movel	%sp@+,%d0
55bebf6897Sthorpej	movel	%sp@+,%d1
56c78325aeSis#endif
57c78325aeSis	rts
58