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, 1996 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 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
139 andcc RES_PTR,4,%g0 ! RES_PTR unaligned? Side effect: cy=0
140 be LOC(v1b) ! if no, branch
142 /* Add least significant limb separately to align RES_PTR and S1_PTR */
150 add RES_PTR,4,RES_PTR
152 addx %g0,%g0,%o4 ! save cy in register
153 cmp SIZE,2 ! if SIZE < 2 ...
154 bl LOC(end2) ! ... branch to tail code
155 subcc %g0,%o4,%g0 ! restore cy
162 subcc %g0,%o4,%g0 ! restore cy
163 /* Add blocks of 8 limbs until less than 8 limbs remain */
189 addx %g0,%g0,%o4 ! save cy in register
193 add RES_PTR,32,RES_PTR
195 subcc %g0,%o4,%g0 ! restore cy
200 subcc %g0,%o4,%g0 ! restore cy
201 /* Add blocks of 2 limbs until less than 2 limbs remain */
209 addx %g0,%g0,%o4 ! save cy in register
213 add RES_PTR,8,RES_PTR
215 subcc %g0,%o4,%g0 ! restore cy
220 addx %g0,%g0,%o4 ! save cy in register
224 subcc %g0,%o4,%g0 ! restore cy
233 addx %g0,%g0,%o0 ! return carry-out from most sign. limb
236 /* If we come here, the alignment of S1_PTR and RES_PTR as well as the
237 alignment of S2_PTR and RES_PTR differ. Since there are only two ways
238 things can be aligned (that we care about) we now know that the alignment
239 of S1_PTR and S2_PTR are the same. */
244 andcc S1_PTR,4,%g0 ! S1_PTR unaligned? Side effect: cy=0
245 be LOC(v2) ! if no, branch
247 /* Add least significant limb separately to align S1_PTR and S2_PTR */
255 add RES_PTR,4,RES_PTR
258 addx %g0,%g0,%o4 ! save cy in register
261 subcc %g0,%o4,%g0 ! restore cy
262 /* Add blocks of 8 limbs until less than 8 limbs remain */
288 addx %g0,%g0,%o4 ! save cy in register
292 add RES_PTR,32,RES_PTR
294 subcc %g0,%o4,%g0 ! restore cy
299 subcc %g0,%o4,%g0 ! restore cy
307 addx %g0,%g0,%o4 ! save cy in register
311 add RES_PTR,8,RES_PTR
313 subcc %g0,%o4,%g0 ! restore cy
317 subcc %g0,%o4,%g0 ! restore cy
327 addx %g0,%g0,%o0 ! return carry-out from most sign. limb