1 ! SPARC __mpn_add_n -- Add two limb vectors of the same length > 0 and store
2 ! sum in a third limb vector.
4 ! Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
6 ! This file is part of the GNU MP Library.
8 ! The GNU MP Library is free software; you can redistribute it and/or modify
9 ! it under the terms of the GNU Lesser General Public License as published by
10 ! the Free Software Foundation; either version 2.1 of the License, or (at your
11 ! option) any later version.
13 ! The GNU MP Library is distributed in the hope that it will be useful, but
14 ! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 ! License for more details.
18 ! You should have received a copy of the GNU Lesser General Public License
19 ! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20 ! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
33 xor S2_PTR,RES_PTR,%g1
35 bne LOC(1) ! branch if alignment differs
38 LOC(0): andcc RES_PTR,4,%g0 ! RES_PTR unaligned? Side effect: cy=0
39 be LOC(v1) ! if no, branch
41 /* Add least significant limb separately to align RES_PTR and S2_PTR */
51 addx %g0,%g0,%o4 ! save cy in register
52 cmp SIZE,2 ! if SIZE < 2 ...
53 bl LOC(end2) ! ... branch to tail code
54 subcc %g0,%o4,%g0 ! restore cy
61 subcc %g0,%o4,%g0 ! restore cy
62 /* Add blocks of 8 limbs until less than 8 limbs remain */
88 addx %g0,%g0,%o4 ! save cy in register
92 add RES_PTR,32,RES_PTR
94 subcc %g0,%o4,%g0 ! restore cy
99 subcc %g0,%o4,%g0 ! restore cy
100 /* Add blocks of 2 limbs until less than 2 limbs remain */
108 addx %g0,%g0,%o4 ! save cy in register
112 add RES_PTR,8,RES_PTR
114 subcc %g0,%o4,%g0 ! restore cy
119 addx %g0,%g0,%o4 ! save cy in register
123 subcc %g0,%o4,%g0 ! restore cy
132 addx %g0,%g0,%o0 ! return carry-out from most sign. limb
134 LOC(1): xor S1_PTR,RES_PTR,%g1
145 /* If we come here, the alignment of S1_PTR and RES_PTR as well as the
146 alignment of S2_PTR and RES_PTR differ. Since there are only two ways
147 things can be aligned (that we care about) we now know that the alignment
148 of S1_PTR and S2_PTR are the same. */
153 andcc S1_PTR,4,%g0 ! S1_PTR unaligned? Side effect: cy=0
154 be LOC(v2) ! if no, branch
156 /* Add least significant limb separately to align S1_PTR and S2_PTR */
164 add RES_PTR,4,RES_PTR
167 addx %g0,%g0,%o4 ! save cy in register
170 subcc %g0,%o4,%g0 ! restore cy
171 /* Add blocks of 8 limbs until less than 8 limbs remain */
197 addx %g0,%g0,%o4 ! save cy in register
201 add RES_PTR,32,RES_PTR
203 subcc %g0,%o4,%g0 ! restore cy
208 subcc %g0,%o4,%g0 ! restore cy
216 addx %g0,%g0,%o4 ! save cy in register
220 add RES_PTR,8,RES_PTR
222 subcc %g0,%o4,%g0 ! restore cy
226 subcc %g0,%o4,%g0 ! restore cy
236 addx %g0,%g0,%o0 ! return carry-out from most sign. limb