xref: /netbsd-src/lib/libc/arch/m68k/stdlib/abs.S (revision 440d829b3c5ca2f333fbbcaecae64e45ebd2834c)
1*440d829bSmatt/*	$NetBSD: abs.S,v 1.8 2013/07/16 21:48:32 matt Exp $	*/
295735045Sthorpej
35f709618Spaulus/*-
45f709618Spaulus * Copyright (c) 1990 The Regents of the University of California.
55f709618Spaulus * All rights reserved.
65f709618Spaulus *
75f709618Spaulus * This code is derived from software contributed to Berkeley by
85f709618Spaulus * the Systems Programming Group of the University of Utah Computer
95f709618Spaulus * Science Department.
105f709618Spaulus *
115f709618Spaulus * Redistribution and use in source and binary forms, with or without
125f709618Spaulus * modification, are permitted provided that the following conditions
135f709618Spaulus * are met:
145f709618Spaulus * 1. Redistributions of source code must retain the above copyright
155f709618Spaulus *    notice, this list of conditions and the following disclaimer.
165f709618Spaulus * 2. Redistributions in binary form must reproduce the above copyright
175f709618Spaulus *    notice, this list of conditions and the following disclaimer in the
185f709618Spaulus *    documentation and/or other materials provided with the distribution.
19eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors
205f709618Spaulus *    may be used to endorse or promote products derived from this software
215f709618Spaulus *    without specific prior written permission.
225f709618Spaulus *
235f709618Spaulus * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
245f709618Spaulus * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
255f709618Spaulus * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
265f709618Spaulus * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
275f709618Spaulus * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
285f709618Spaulus * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
295f709618Spaulus * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
305f709618Spaulus * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
315f709618Spaulus * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
325f709618Spaulus * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
335f709618Spaulus * SUCH DAMAGE.
345f709618Spaulus */
355f709618Spaulus
36d0fed6c8Sthorpej#include <machine/asm.h>
3795735045Sthorpej
385f709618Spaulus#if defined(LIBC_SCCS) && !defined(lint)
3995735045Sthorpej#if 0
4095735045Sthorpej	RCSID("from: @(#)abs.s	5.1 (Berkeley) 5/12/90")
4195735045Sthorpej#else
42*440d829bSmatt	RCSID("$NetBSD: abs.S,v 1.8 2013/07/16 21:48:32 matt Exp $")
4395735045Sthorpej#endif
445f709618Spaulus#endif /* LIBC_SCCS and not lint */
455f709618Spaulus
46aaed06d4Sis/* labs - long int absolute value */
47aaed06d4Sis
48aaed06d4SisENTRY_NOPROFILE(labs)
49aaed06d4Sis/* fall through to: */
50aaed06d4Sis
515f709618Spaulus/* abs - int absolute value */
525f709618Spaulus
535f709618SpaulusENTRY(abs)
5407a0a325Smatt	movl	4(%sp),%d0
555f709618Spaulus	jge	L1
563b435a73Sthorpej	negl	%d0
575f709618SpaulusL1:
585f709618Spaulus	rts
59*440d829bSmattEND(abs)
60