xref: /onnv-gate/usr/src/lib/libc/amd64/gen/abs.s (revision 7298:b69e27387f74)
10Sstevel@tonic-gate/*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
56812Sraf * Common Development and Distribution License (the "License").
66812Sraf * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
211219Sraf
220Sstevel@tonic-gate/*
236812Sraf * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
27*7298SMark.J.Nelson@Sun.COM	.file	"abs.s"
280Sstevel@tonic-gate
290Sstevel@tonic-gate/*
300Sstevel@tonic-gate *	Assembler program to implement the following C program
310Sstevel@tonic-gate *
320Sstevel@tonic-gate *	int
330Sstevel@tonic-gate *	abs(int arg)
340Sstevel@tonic-gate *	{
350Sstevel@tonic-gate *		return((arg < 0)? -arg: arg);
360Sstevel@tonic-gate *	}
370Sstevel@tonic-gate */
380Sstevel@tonic-gate
390Sstevel@tonic-gate#include "SYS.h"
400Sstevel@tonic-gate
410Sstevel@tonic-gate	ENTRY(abs)
420Sstevel@tonic-gate	movl	%edi, %eax
430Sstevel@tonic-gate	testl	%eax, %eax	/* arg < 0? */
440Sstevel@tonic-gate	jns	1f
450Sstevel@tonic-gate	negl	%eax		/* yes, return -arg */
460Sstevel@tonic-gate1:
470Sstevel@tonic-gate	ret
480Sstevel@tonic-gate	SET_SIZE(abs)
490Sstevel@tonic-gate
500Sstevel@tonic-gate 	ENTRY(labs)
510Sstevel@tonic-gate 	movq	%rdi, %rax
520Sstevel@tonic-gate 	testq	%rax, %rax	/* arg < 0? */
530Sstevel@tonic-gate 	jns	1f
540Sstevel@tonic-gate 	negq	%rax		/* yes, return -arg */
550Sstevel@tonic-gate1:
560Sstevel@tonic-gate 	ret
570Sstevel@tonic-gate 	SET_SIZE(labs)
581219Sraf
591219Sraf 	ENTRY(llabs)
601219Sraf 	movq	%rdi, %rax
611219Sraf 	testq	%rax, %rax	/* arg < 0? */
621219Sraf 	jns	1f
631219Sraf 	negq	%rax		/* yes, return -arg */
641219Sraf1:
651219Sraf 	ret
661219Sraf 	SET_SIZE(llabs)
67