Blame sysdeps/sparc/sparc64/add_n.S

Packit 6c4009
/* SPARC v9 __mpn_add_n -- Add two limb vectors of the same length > 0 and
Packit 6c4009
   store sum in a third limb vector.
Packit 6c4009
Packit 6c4009
   Copyright (C) 1995-2018 Free Software Foundation, Inc.
Packit 6c4009
Packit 6c4009
   This file is part of the GNU MP Library.
Packit 6c4009
Packit 6c4009
   The GNU MP Library is free software; you can redistribute it and/or modify
Packit 6c4009
   it under the terms of the GNU Lesser General Public License as published by
Packit 6c4009
   the Free Software Foundation; either version 2.1 of the License, or (at your
Packit 6c4009
   option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU MP Library is distributed in the hope that it will be useful, but
Packit 6c4009
   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 6c4009
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
Packit 6c4009
   License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public License
Packit 6c4009
   along with the GNU MP Library; see the file COPYING.LIB.  If not,
Packit 6c4009
   see <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* INPUT PARAMETERS
Packit 6c4009
   res_ptr	%o0
Packit 6c4009
   s1_ptr	%o1
Packit 6c4009
   s2_ptr	%o2
Packit 6c4009
   size		%o3  */
Packit 6c4009
Packit 6c4009
Packit 6c4009
ENTRY(__mpn_add_n)
Packit 6c4009
Packit 6c4009
	sub	%g0,%o3,%g5
Packit 6c4009
	sllx	%o3,3,%g1
Packit 6c4009
	add	%o1,%g1,%o1		! make s1_ptr point at end
Packit 6c4009
	add	%o2,%g1,%o2		! make s2_ptr point at end
Packit 6c4009
	add	%o0,%g1,%o0		! make res_ptr point at end
Packit 6c4009
	mov	0,%o4			! clear carry variable
Packit 6c4009
	sllx	%g5,3,%o5		! compute initial address index
Packit 6c4009
Packit 6c4009
1:	ldx	[%o2+%o5],%g1		! load s2 limb
Packit 6c4009
	add	%g5,1,%g5		! increment loop count
Packit 6c4009
	ldx	[%o1+%o5],%o3		! load s1 limb
Packit 6c4009
	addcc	%g1,%o4,%g1		! add s2 limb and carry variable
Packit 6c4009
	movcc	%xcc,0,%o4		! if carry-out, o4 was 1; clear it
Packit 6c4009
	addcc	%g1,%o3,%g1		! add s1 limb to sum
Packit 6c4009
	stx	%g1,[%o0+%o5]		! store result
Packit 6c4009
	add	%o5,8,%o5		! increment address index
Packit 6c4009
	brnz,pt	%g5,1b
Packit 6c4009
	 movcs	%xcc,1,%o4		! if s1 add gave carry, record it
Packit 6c4009
Packit 6c4009
	retl
Packit 6c4009
	 mov %o4,%o0
Packit 6c4009
Packit 6c4009
END(__mpn_add_n)