1 ! SPARC __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
2 ! store difference in a third limb vector.
4 ! Copyright (C) 1995-2023 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,
20 ! see <https://www.gnu.org/licenses/>.
32 xor S2_PTR,RES_PTR,%g1
34 bne LOC(1) ! branch if alignment differs
37 andcc RES_PTR,4,%g0 ! RES_PTR unaligned? Side effect: cy=0
38 be LOC(v1) ! if no, branch
40 /* Add least significant limb separately to align RES_PTR and S2_PTR */
50 addx %g0,%g0,%o4 ! save cy in register
51 cmp SIZE,2 ! if SIZE < 2 ...
52 bl LOC(end2) ! ... branch to tail code
53 subcc %g0,%o4,%g0 ! restore cy
60 subcc %g0,%o4,%g0 ! restore cy
61 /* Add blocks of 8 limbs until less than 8 limbs remain */
87 addx %g0,%g0,%o4 ! save cy in register
91 add RES_PTR,32,RES_PTR
93 subcc %g0,%o4,%g0 ! restore cy
98 subcc %g0,%o4,%g0 ! restore cy
99 /* Add blocks of 2 limbs until less than 2 limbs remain */
107 addx %g0,%g0,%o4 ! save cy in register
111 add RES_PTR,8,RES_PTR
113 subcc %g0,%o4,%g0 ! restore cy
118 addx %g0,%g0,%o4 ! save cy in register
122 subcc %g0,%o4,%g0 ! restore cy
131 addx %g0,%g0,%o0 ! return carry-out from most sign. limb
133 LOC(1): xor S1_PTR,RES_PTR,%g1
138 andcc RES_PTR,4,%g0 ! RES_PTR unaligned? Side effect: cy=0
139 be LOC(v1b) ! if no, branch
141 /* Add least significant limb separately to align RES_PTR and S1_PTR */
149 add RES_PTR,4,RES_PTR
151 addx %g0,%g0,%o4 ! save cy in register
152 cmp SIZE,2 ! if SIZE < 2 ...
153 bl LOC(end2) ! ... branch to tail code
154 subcc %g0,%o4,%g0 ! restore cy
161 subcc %g0,%o4,%g0 ! restore cy
162 /* Add blocks of 8 limbs until less than 8 limbs remain */
188 addx %g0,%g0,%o4 ! save cy in register
192 add RES_PTR,32,RES_PTR
194 subcc %g0,%o4,%g0 ! restore cy
199 subcc %g0,%o4,%g0 ! restore cy
200 /* Add blocks of 2 limbs until less than 2 limbs remain */
208 addx %g0,%g0,%o4 ! save cy in register
212 add RES_PTR,8,RES_PTR
214 subcc %g0,%o4,%g0 ! restore cy
219 addx %g0,%g0,%o4 ! save cy in register
223 subcc %g0,%o4,%g0 ! restore cy
232 addx %g0,%g0,%o0 ! return carry-out from most sign. limb
235 /* If we come here, the alignment of S1_PTR and RES_PTR as well as the
236 alignment of S2_PTR and RES_PTR differ. Since there are only two ways
237 things can be aligned (that we care about) we now know that the alignment
238 of S1_PTR and S2_PTR are the same. */
243 andcc S1_PTR,4,%g0 ! S1_PTR unaligned? Side effect: cy=0
244 be LOC(v2) ! if no, branch
246 /* Add least significant limb separately to align S1_PTR and S2_PTR */
254 add RES_PTR,4,RES_PTR
257 addx %g0,%g0,%o4 ! save cy in register
260 subcc %g0,%o4,%g0 ! restore cy
261 /* Add blocks of 8 limbs until less than 8 limbs remain */
287 addx %g0,%g0,%o4 ! save cy in register
291 add RES_PTR,32,RES_PTR
293 subcc %g0,%o4,%g0 ! restore cy
298 subcc %g0,%o4,%g0 ! restore cy
306 addx %g0,%g0,%o4 ! save cy in register
310 add RES_PTR,8,RES_PTR
312 subcc %g0,%o4,%g0 ! restore cy
316 subcc %g0,%o4,%g0 ! restore cy
326 addx %g0,%g0,%o0 ! return carry-out from most sign. limb