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 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 3 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. If not, see http://www.gnu.org/licenses/.
22 include(`../config.m4')
32 xor s2_ptr,res_ptr,%g1
34 bne L(1) C branch if alignment differs
37 L(0): andcc res_ptr,4,%g0 C res_ptr unaligned? Side effect: cy=0
38 be L(v1) C if no, branch
40 C Add least significant limb separately to align res_ptr and s2_ptr
49 L(v1): addx %g0,%g0,%o4 C save cy in register
50 cmp n,2 C if n < 2 ...
51 bl L(end2) C ... branch to tail code
52 subcc %g0,%o4,%g0 C restore cy
59 subcc %g0,%o4,%g0 C restore cy
60 C Add blocks of 8 limbs until less than 8 limbs remain
86 addx %g0,%g0,%o4 C save cy in register
90 add res_ptr,32,res_ptr
92 subcc %g0,%o4,%g0 C restore cy
97 subcc %g0,%o4,%g0 C restore cy
98 C Add blocks of 2 limbs until less than 2 limbs remain
106 addx %g0,%g0,%o4 C save cy in register
110 add res_ptr,8,res_ptr
112 subcc %g0,%o4,%g0 C restore cy
117 addx %g0,%g0,%o4 C save cy in register
121 subcc %g0,%o4,%g0 C restore cy
130 addx %g0,%g0,%o0 C return carry-out from most sign. limb
132 L(1): xor s1_ptr,res_ptr,%g1
143 C If we come here, the alignment of s1_ptr and res_ptr as well as the
144 C alignment of s2_ptr and res_ptr differ. Since there are only two ways
145 C things can be aligned (that we care about) we now know that the alignment
146 C of s1_ptr and s2_ptr are the same.
151 andcc s1_ptr,4,%g0 C s1_ptr unaligned? Side effect: cy=0
152 be L(v2) C if no, branch
154 C Add least significant limb separately to align s1_ptr and s2_ptr
162 add res_ptr,4,res_ptr
164 L(v2): addx %g0,%g0,%o4 C save cy in register
167 subcc %g0,%o4,%g0 C restore cy
168 C Add blocks of 8 limbs until less than 8 limbs remain
194 addx %g0,%g0,%o4 C save cy in register
198 add res_ptr,32,res_ptr
200 subcc %g0,%o4,%g0 C restore cy
205 subcc %g0,%o4,%g0 C restore cy
213 addx %g0,%g0,%o4 C save cy in register
217 add res_ptr,8,res_ptr
219 subcc %g0,%o4,%g0 C restore cy
223 subcc %g0,%o4,%g0 C restore cy
233 addx %g0,%g0,%o0 C return carry-out from most sign. limb