1*ef132276Sisaki/* $NetBSD: s_floor.S,v 1.9 2014/08/10 13:30:43 isaki Exp $ */ 2bebf6897Sthorpej 3455f7bb9Sis/*- 4455f7bb9Sis * Copyright (c) 1990 The Regents of the University of California. 5455f7bb9Sis * All rights reserved. 6455f7bb9Sis * 7455f7bb9Sis * This code is derived from software contributed to Berkeley by 8455f7bb9Sis * the Systems Programming Group of the University of Utah Computer 9455f7bb9Sis * Science Department. 10455f7bb9Sis * 11455f7bb9Sis * Redistribution and use in source and binary forms, with or without 12455f7bb9Sis * modification, are permitted provided that the following conditions 13455f7bb9Sis * are met: 14455f7bb9Sis * 1. Redistributions of source code must retain the above copyright 15455f7bb9Sis * notice, this list of conditions and the following disclaimer. 16455f7bb9Sis * 2. Redistributions in binary form must reproduce the above copyright 17455f7bb9Sis * notice, this list of conditions and the following disclaimer in the 18455f7bb9Sis * documentation and/or other materials provided with the distribution. 19eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors 20455f7bb9Sis * may be used to endorse or promote products derived from this software 21455f7bb9Sis * without specific prior written permission. 22455f7bb9Sis * 23455f7bb9Sis * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24455f7bb9Sis * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25455f7bb9Sis * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26455f7bb9Sis * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27455f7bb9Sis * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28455f7bb9Sis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29455f7bb9Sis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30455f7bb9Sis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31455f7bb9Sis * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32455f7bb9Sis * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33455f7bb9Sis * SUCH DAMAGE. 34455f7bb9Sis */ 35455f7bb9Sis 36455f7bb9Sis#include <machine/asm.h> 37455f7bb9Sis 38455f7bb9Sis;_sccsid: 39455f7bb9Sis;.asciz "from: @(#)floor.s 5.1 (Berkeley) 5/17/90" 40455f7bb9Sis 41*ef132276SisakiRCSID("$NetBSD: s_floor.S,v 1.9 2014/08/10 13:30:43 isaki Exp $") 42455f7bb9Sis 43455f7bb9Sis| floor(x) 44455f7bb9Sis| the largest integer no larger than x 45455f7bb9SisENTRY(floor) 46bebf6897Sthorpej fmovel %fpcr,%d0 | save old FPCR 47bebf6897Sthorpej fmoved %sp@(4),%fp0 | get argument 48455f7bb9Sis fbun Lret | if NaN, return NaN 49914e175cSisaki fmovel #0x20,%fpcr | round to -inf 50*ef132276Sisaki fintx %fp0 | truncate 51bebf6897Sthorpej fmovel %d0,%fpcr | restore old FPCR 52455f7bb9SisLret: 53455f7bb9Sis#ifndef __SVR4_ABI__ 54bebf6897Sthorpej fmoved %fp0,%sp@- 55bebf6897Sthorpej movel %sp@+,%d0 56bebf6897Sthorpej movel %sp@+,%d1 57455f7bb9Sis#endif 58455f7bb9Sis rts 59