xref: /minix3/lib/libc/arch/m68k/hardfloat/fixunssfsi.S (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc/*	$NetBSD: fixunssfsi.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $	*/
284d9c625SLionel Sambuc
384d9c625SLionel Sambuc/*-
484d9c625SLionel Sambuc * Copyright (c) 1990 The Regents of the University of California.
584d9c625SLionel Sambuc * All rights reserved.
684d9c625SLionel Sambuc *
784d9c625SLionel Sambuc * This code is derived from software contributed to Berkeley by
884d9c625SLionel Sambuc * the Systems Programming Group of the University of Utah Computer
984d9c625SLionel Sambuc * Science Department.
1084d9c625SLionel Sambuc *
1184d9c625SLionel Sambuc * Redistribution and use in source and binary forms, with or without
1284d9c625SLionel Sambuc * modification, are permitted provided that the following conditions
1384d9c625SLionel Sambuc * are met:
1484d9c625SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
1584d9c625SLionel Sambuc *    notice, this list of conditions and the following disclaimer.
1684d9c625SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
1784d9c625SLionel Sambuc *    notice, this list of conditions and the following disclaimer in the
1884d9c625SLionel Sambuc *    documentation and/or other materials provided with the distribution.
1984d9c625SLionel Sambuc * 3. Neither the name of the University nor the names of its contributors
2084d9c625SLionel Sambuc *    may be used to endorse or promote products derived from this software
2184d9c625SLionel Sambuc *    without specific prior written permission.
2284d9c625SLionel Sambuc *
2384d9c625SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2484d9c625SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2584d9c625SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2684d9c625SLionel Sambuc * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2784d9c625SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2884d9c625SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2984d9c625SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3084d9c625SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3184d9c625SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3284d9c625SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3384d9c625SLionel Sambuc * SUCH DAMAGE.
3484d9c625SLionel Sambuc */
3584d9c625SLionel Sambuc
3684d9c625SLionel Sambuc#include <machine/asm.h>
3784d9c625SLionel Sambuc
3884d9c625SLionel Sambuc#if defined(LIBC_SCCS) && !defined(lint)
3984d9c625SLionel Sambuc#if 0
4084d9c625SLionel Sambuc	RCSID("from: @(#)fixunssfsi.s	5.1 (Berkeley) 6/7/90")
4184d9c625SLionel Sambuc#else
42*0a6a1f1dSLionel Sambuc	RCSID("$NetBSD: fixunssfsi.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $")
4384d9c625SLionel Sambuc#endif
4484d9c625SLionel Sambuc#endif /* LIBC_SCCS and not lint */
4584d9c625SLionel Sambuc
4684d9c625SLionel Sambuc#ifdef __mcoldfire__
4784d9c625SLionel Sambuc	.section .rodata,"a"
4884d9c625SLionel Sambuc	.p2align 4
4984d9c625SLionel SambucL2G:	.double 0r2147483648.0
5084d9c625SLionel Sambuc#endif
5184d9c625SLionel Sambuc
5284d9c625SLionel Sambuc/* single -> unsigned */
5384d9c625SLionel SambucENTRY(__fixunssfsi)
5484d9c625SLionel Sambuc	fintrzs	4(%sp),%fp0
5584d9c625SLionel Sambuc#ifdef __mcoldfire__
5684d9c625SLionel Sambuc	LEA_LCL(L2G,%a0)
5784d9c625SLionel Sambuc	fmoved	(%a0),%fp1
5884d9c625SLionel Sambuc	fcmpd	%fp1,%fp0
5984d9c625SLionel Sambuc#else
6084d9c625SLionel Sambuc	fmoved	#0r2147483648.0,%fp1
6184d9c625SLionel Sambuc	fcmpx	%fp1,%fp0
6284d9c625SLionel Sambuc#endif
6384d9c625SLionel Sambuc	fbge	Lwaybig
6484d9c625SLionel Sambuc	fmovel	%fp0,%d0
6584d9c625SLionel Sambuc	rts
6684d9c625SLionel SambucLwaybig:
6784d9c625SLionel Sambuc#ifdef __mcoldfire__
6884d9c625SLionel Sambuc	fsubd	%fp1,%fp0
6984d9c625SLionel Sambuc#else
7084d9c625SLionel Sambuc	fsubx	%fp1,%fp0
7184d9c625SLionel Sambuc#endif
7284d9c625SLionel Sambuc	fmovel	%fp0,%d0
7384d9c625SLionel Sambuc	bset	#31,%d0
7484d9c625SLionel Sambuc	rts
7584d9c625SLionel SambucEND(__fixunssfsi)
76