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
either:
11 dnl
* the GNU Lesser General
Public License as published by the Free
12 dnl Software Foundation
; either version 3 of the License, or (at your
13 dnl option
) any later version.
17 dnl
* the GNU General
Public License as published by the Free Software
18 dnl Foundation
; either version 2 of the License, or (at your option) any
21 dnl
or both
in parallel
, as here.
23 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
24 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
25 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
28 dnl You should have received copies of the GNU General
Public License
and the
29 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
30 dnl see
https://www.gnu.
org/licenses
/.
33 include(`..
/config.m4
')
43 xor s2_ptr,res_ptr,%g1
45 bne L(1) C branch if alignment differs
48 L(0): andcc res_ptr,4,%g0 C res_ptr unaligned? Side effect: cy=0
49 be L(v1) C if no, branch
51 C Add least significant limb separately to align res_ptr and s2_ptr
60 L(v1): addx %g0,%g0,%o4 C save cy in register
61 cmp n,2 C if n < 2 ...
62 bl L(end2) C ... branch to tail code
63 subcc %g0,%o4,%g0 C restore cy
70 subcc %g0,%o4,%g0 C restore cy
71 C Add blocks of 8 limbs until less than 8 limbs remain
97 addx %g0,%g0,%o4 C save cy in register
101 add res_ptr,32,res_ptr
103 subcc %g0,%o4,%g0 C restore cy
108 subcc %g0,%o4,%g0 C restore cy
109 C Add blocks of 2 limbs until less than 2 limbs remain
117 addx %g0,%g0,%o4 C save cy in register
121 add res_ptr,8,res_ptr
123 subcc %g0,%o4,%g0 C restore cy
128 addx %g0,%g0,%o4 C save cy in register
132 subcc %g0,%o4,%g0 C restore cy
141 addx %g0,%g0,%o0 C return carry-out from most sign. limb
143 L(1): xor s1_ptr,res_ptr,%g1
154 C If we come here, the alignment of s1_ptr and res_ptr as well as the
155 C alignment of s2_ptr and res_ptr differ. Since there are only two ways
156 C things can be aligned (that we care about) we now know that the alignment
157 C of s1_ptr and s2_ptr are the same.
162 andcc s1_ptr,4,%g0 C s1_ptr unaligned? Side effect: cy=0
163 be L(v2) C if no, branch
165 C Add least significant limb separately to align s1_ptr and s2_ptr
173 add res_ptr,4,res_ptr
175 L(v2): addx %g0,%g0,%o4 C save cy in register
178 subcc %g0,%o4,%g0 C restore cy
179 C Add blocks of 8 limbs until less than 8 limbs remain
205 addx %g0,%g0,%o4 C save cy in register
209 add res_ptr,32,res_ptr
211 subcc %g0,%o4,%g0 C restore cy
216 subcc %g0,%o4,%g0 C restore cy
224 addx %g0,%g0,%o4 C save cy in register
228 add res_ptr,8,res_ptr
230 subcc %g0,%o4,%g0 C restore cy
234 subcc %g0,%o4,%g0 C restore cy
244 addx %g0,%g0,%o0 C return carry-out from most sign. limb