xref: /netbsd-src/lib/libm/arch/m68k/s_copysign.S (revision f23a56fd5e13a660ac180741ec601a286b1e2cc6)
1*f23a56fdSjoerg/*	$NetBSD: s_copysign.S,v 1.10 2014/11/16 16:11:33 joerg Exp $	*/
2bebf6897Sthorpej
311d34cdcSis/*-
411d34cdcSis * Copyright (c) 1990 The Regents of the University of California.
511d34cdcSis * All rights reserved.
611d34cdcSis *
711d34cdcSis * This code is derived from software contributed to Berkeley by
811d34cdcSis * the Systems Programming Group of the University of Utah Computer
911d34cdcSis * Science Department.
1011d34cdcSis *
1111d34cdcSis * Redistribution and use in source and binary forms, with or without
1211d34cdcSis * modification, are permitted provided that the following conditions
1311d34cdcSis * are met:
1411d34cdcSis * 1. Redistributions of source code must retain the above copyright
1511d34cdcSis *    notice, this list of conditions and the following disclaimer.
1611d34cdcSis * 2. Redistributions in binary form must reproduce the above copyright
1711d34cdcSis *    notice, this list of conditions and the following disclaimer in the
1811d34cdcSis *    documentation and/or other materials provided with the distribution.
19eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors
2011d34cdcSis *    may be used to endorse or promote products derived from this software
2111d34cdcSis *    without specific prior written permission.
2211d34cdcSis *
2311d34cdcSis * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2411d34cdcSis * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2511d34cdcSis * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2611d34cdcSis * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2711d34cdcSis * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2811d34cdcSis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2911d34cdcSis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3011d34cdcSis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3111d34cdcSis * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3211d34cdcSis * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3311d34cdcSis * SUCH DAMAGE.
3411d34cdcSis */
3511d34cdcSis
3611d34cdcSis#include <machine/asm.h>
37*f23a56fdSjoerg#include <machine/math.h>
3811d34cdcSis
3911d34cdcSis;_sccsid:
4011d34cdcSis;.asciz	"from: @(#)support.s	5.2 (Berkeley) 5/17/90"
4111d34cdcSis
42*f23a56fdSjoergRCSID("$NetBSD: s_copysign.S,v 1.10 2014/11/16 16:11:33 joerg Exp $")
432583a98bSjoerg
44*f23a56fdSjoerg#if !defined(__HAVE_LONG_DOUBLE)
45797e9a24SjoergSTRONG_ALIAS(_copysignl, copysign)
462583a98bSjoergWEAK_ALIAS(copysignl, _copysignl)
47*f23a56fdSjoerg#endif
4811d34cdcSis
4911d34cdcSis| copysign(x,y)
5011d34cdcSis| returns x with the sign of y.
5111d34cdcSisENTRY(copysign)
5211d34cdcSis#ifdef __SVR4_ABI__
53bebf6897Sthorpej	tstw	%sp@(12)
5411d34cdcSis	jmi	Lneg
55bebf6897Sthorpej	bclr	#31,%sp@(4)
56bebf6897Sthorpej	fmoved	%sp@(4),%fp0
5711d34cdcSis	rts
5811d34cdcSisLneg:
59bebf6897Sthorpej	bset	#31,%sp@(4)
60bebf6897Sthorpej	fmoved	%sp@(4),%fp0
6111d34cdcSis	rts
6211d34cdcSis#else
63bebf6897Sthorpej	movl	%sp@(4),%d0
64bebf6897Sthorpej	movl	%sp@(8),%d1
65bebf6897Sthorpej	tstw	%sp@(12)
6611d34cdcSis	jmi	Lneg
67bebf6897Sthorpej	bclr	#31,%d0
6811d34cdcSis	rts
6911d34cdcSisLneg:
70bebf6897Sthorpej	bset	#31,%d0
7111d34cdcSis	rts
7211d34cdcSis#endif
73