1 dnl SPARC mpn_add_n -- Add two limb vectors of the same length > 0 and store
2 dnl sum in a third limb vector.
4 dnl Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc.
6 dnl This file is part of the GNU MP Library.
8 dnl The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl it under the terms of the GNU Lesser General Public License as published
10 dnl by the Free Software Foundation; either version 2.1 of the License, or (at
11 dnl your option) any later version.
13 dnl The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 dnl License for more details.
18 dnl You should have received a copy of the GNU Lesser General Public License
19 dnl along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20 dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 dnl MA 02111-1307, USA.
24 include(`../config.m4')
34 xor s2_ptr,res_ptr,%g1
36 bne L(1) C branch if alignment differs
39 L(0): andcc res_ptr,4,%g0 C res_ptr unaligned? Side effect: cy=0
40 be L(v1) C if no, branch
42 C Add least significant limb separately to align res_ptr and s2_ptr
51 L(v1): addx %g0,%g0,%o4 C save cy in register
52 cmp n,2 C if n < 2 ...
53 bl L(end2) C ... branch to tail code
54 subcc %g0,%o4,%g0 C restore cy
61 subcc %g0,%o4,%g0 C restore cy
62 C Add blocks of 8 limbs until less than 8 limbs remain
88 addx %g0,%g0,%o4 C save cy in register
92 add res_ptr,32,res_ptr
94 subcc %g0,%o4,%g0 C restore cy
99 subcc %g0,%o4,%g0 C restore cy
100 C Add blocks of 2 limbs until less than 2 limbs remain
108 addx %g0,%g0,%o4 C save cy in register
112 add res_ptr,8,res_ptr
114 subcc %g0,%o4,%g0 C restore cy
119 addx %g0,%g0,%o4 C save cy in register
123 subcc %g0,%o4,%g0 C restore cy
132 addx %g0,%g0,%o0 C return carry-out from most sign. limb
134 L(1): xor s1_ptr,res_ptr,%g1
145 C If we come here, the alignment of s1_ptr and res_ptr as well as the
146 C alignment of s2_ptr and res_ptr differ. Since there are only two ways
147 C things can be aligned (that we care about) we now know that the alignment
148 C of s1_ptr and s2_ptr are the same.
153 andcc s1_ptr,4,%g0 C s1_ptr unaligned? Side effect: cy=0
154 be L(v2) C if no, branch
156 C Add least significant limb separately to align s1_ptr and s2_ptr
164 add res_ptr,4,res_ptr
166 L(v2): addx %g0,%g0,%o4 C save cy in register
169 subcc %g0,%o4,%g0 C restore cy
170 C Add blocks of 8 limbs until less than 8 limbs remain
196 addx %g0,%g0,%o4 C save cy in register
200 add res_ptr,32,res_ptr
202 subcc %g0,%o4,%g0 C restore cy
207 subcc %g0,%o4,%g0 C restore cy
215 addx %g0,%g0,%o4 C save cy in register
219 add res_ptr,8,res_ptr
221 subcc %g0,%o4,%g0 C restore cy
225 subcc %g0,%o4,%g0 C restore cy
235 addx %g0,%g0,%o0 C return carry-out from most sign. limb