xref: /netbsd-src/lib/libc/arch/m68k/hardfloat/fixunsdfsi.S (revision 6cb10275d08f045e872662c371fe2f2724f2f6e6)
1*6cb10275Sriastradh/*	$NetBSD: fixunsdfsi.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $	*/
2d35c3886Smatt
3d35c3886Smatt/*-
4d35c3886Smatt * Copyright (c) 1990 The Regents of the University of California.
5d35c3886Smatt * All rights reserved.
6d35c3886Smatt *
7d35c3886Smatt * This code is derived from software contributed to Berkeley by
8d35c3886Smatt * the Systems Programming Group of the University of Utah Computer
9d35c3886Smatt * Science Department.
10d35c3886Smatt *
11d35c3886Smatt * Redistribution and use in source and binary forms, with or without
12d35c3886Smatt * modification, are permitted provided that the following conditions
13d35c3886Smatt * are met:
14d35c3886Smatt * 1. Redistributions of source code must retain the above copyright
15d35c3886Smatt *    notice, this list of conditions and the following disclaimer.
16d35c3886Smatt * 2. Redistributions in binary form must reproduce the above copyright
17d35c3886Smatt *    notice, this list of conditions and the following disclaimer in the
18d35c3886Smatt *    documentation and/or other materials provided with the distribution.
19d35c3886Smatt * 3. Neither the name of the University nor the names of its contributors
20d35c3886Smatt *    may be used to endorse or promote products derived from this software
21d35c3886Smatt *    without specific prior written permission.
22d35c3886Smatt *
23d35c3886Smatt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24d35c3886Smatt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25d35c3886Smatt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26d35c3886Smatt * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27d35c3886Smatt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28d35c3886Smatt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29d35c3886Smatt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30d35c3886Smatt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31d35c3886Smatt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32d35c3886Smatt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33d35c3886Smatt * SUCH DAMAGE.
34d35c3886Smatt */
35d35c3886Smatt
36d35c3886Smatt#include <machine/asm.h>
37d35c3886Smatt
38d35c3886Smatt#if defined(LIBC_SCCS) && !defined(lint)
39d35c3886Smatt#if 0
40d35c3886Smatt	RCSID("from: @(#)fixunsdfsi.s	5.1 (Berkeley) 6/7/90")
41d35c3886Smatt#else
42*6cb10275Sriastradh	RCSID("$NetBSD: fixunsdfsi.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $")
43d35c3886Smatt#endif
44d35c3886Smatt#endif /* LIBC_SCCS and not lint */
45d35c3886Smatt
466125de07Smatt#ifdef __mcoldfire__
476125de07Smatt	.section .rodata,"a"
486125de07Smatt	.p2align 4
496125de07SmattL2G:	.double 0r2147483648.0
506125de07Smatt#endif
516125de07Smatt
52d35c3886Smatt/* (unsigned) double */
53d35c3886SmattENTRY(__fixunsdfsi)
54d35c3886Smatt	fintrzd	4(%sp),%fp0
556125de07Smatt#ifdef __mcoldfire__
566125de07Smatt	LEA_LCL(L2G,%a0)
576125de07Smatt	fmoved	(%a0),%fp1
586125de07Smatt	fcmpd	%fp1,%fp0
596125de07Smatt#else
606125de07Smatt	fmoved	#0r2147483648.0,%fp1
616125de07Smatt	fcmpx	%fp1,%fp0
626125de07Smatt#endif
63d35c3886Smatt	fbge	Lwaybig
64d35c3886Smatt	fmovel	%fp0,%d0
65d35c3886Smatt	rts
66d35c3886SmattLwaybig:
676125de07Smatt#ifdef __mcoldfire__
686125de07Smatt	fsubd	%fp1,%fp0
696125de07Smatt#else
706125de07Smatt	fsubx	%fp1,%fp0
716125de07Smatt#endif
72d35c3886Smatt	fmovel	%fp0,%d0
73d35c3886Smatt	bset	#31,%d0
74d35c3886Smatt	rts
75d35c3886SmattEND(__fixunsdfsi)
76