xref: /openbsd-src/lib/libc/arch/sparc64/gen/mul.S (revision 6580fee3295c971a919cc04bfc3598c5f8bcd2b1)
1*6580fee3Smillert/*	$OpenBSD: mul.S,v 1.2 2003/06/02 20:18:32 millert Exp $	*/
27e2260f1Sart/*	$NetBSD: mul.S,v 1.1 1998/09/11 04:56:28 eeh Exp $	*/
37e2260f1Sart
47e2260f1Sart/*
57e2260f1Sart * Copyright (c) 1992, 1993
67e2260f1Sart *	The Regents of the University of California.  All rights reserved.
77e2260f1Sart *
87e2260f1Sart * This software was developed by the Computer Systems Engineering group
97e2260f1Sart * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
107e2260f1Sart * contributed to Berkeley.
117e2260f1Sart *
127e2260f1Sart * Redistribution and use in source and binary forms, with or without
137e2260f1Sart * modification, are permitted provided that the following conditions
147e2260f1Sart * are met:
157e2260f1Sart * 1. Redistributions of source code must retain the above copyright
167e2260f1Sart *    notice, this list of conditions and the following disclaimer.
177e2260f1Sart * 2. Redistributions in binary form must reproduce the above copyright
187e2260f1Sart *    notice, this list of conditions and the following disclaimer in the
197e2260f1Sart *    documentation and/or other materials provided with the distribution.
20*6580fee3Smillert * 3. Neither the name of the University nor the names of its contributors
217e2260f1Sart *    may be used to endorse or promote products derived from this software
227e2260f1Sart *    without specific prior written permission.
237e2260f1Sart *
247e2260f1Sart * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
257e2260f1Sart * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
267e2260f1Sart * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
277e2260f1Sart * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
287e2260f1Sart * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
297e2260f1Sart * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
307e2260f1Sart * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
317e2260f1Sart * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
327e2260f1Sart * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
337e2260f1Sart * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
347e2260f1Sart * SUCH DAMAGE.
357e2260f1Sart */
367e2260f1Sart
377e2260f1Sart#include <machine/asm.h>
387e2260f1Sart
397e2260f1Sart/*
407e2260f1Sart * Signed multiply.
417e2260f1Sart *
427e2260f1Sart * Returns %o0 * %o1 in %o0
437e2260f1Sart *
447e2260f1Sart * According to the manual the smaller parameter should be in
457e2260f1Sart * rs1, so we'll move it there.
467e2260f1Sart */
477e2260f1Sart
487e2260f1SartFUNC(.mul)
497e2260f1Sart	cmp	%o0, %o1
507e2260f1Sart	bge	1f
517e2260f1Sart	 nop
527e2260f1Sart	retl
537e2260f1Sart	 mulx	%o0, %o1, %o0
547e2260f1Sart1:
557e2260f1Sart	retl
567e2260f1Sart	 mulx	%o1, %o0, %o0
57