1 dnl SPARC mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
2 dnl store difference 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 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
137 andcc res_ptr,4,%g0 C res_ptr unaligned? Side effect: cy=0
138 be L(v1b) C if no, branch
140 C Add least significant limb separately to align res_ptr and s1_ptr
148 add res_ptr,4,res_ptr
149 L(v1b): addx %g0,%g0,%o4 C save cy in register
150 cmp n,2 C if n < 2 ...
151 bl L(end2) C ... branch to tail code
152 subcc %g0,%o4,%g0 C restore cy
159 subcc %g0,%o4,%g0 C restore cy
160 C Add blocks of 8 limbs until less than 8 limbs remain
186 addx %g0,%g0,%o4 C save cy in register
190 add res_ptr,32,res_ptr
192 subcc %g0,%o4,%g0 C restore cy
197 subcc %g0,%o4,%g0 C restore cy
198 C Add blocks of 2 limbs until less than 2 limbs remain
206 addx %g0,%g0,%o4 C save cy in register
210 add res_ptr,8,res_ptr
212 subcc %g0,%o4,%g0 C restore cy
217 addx %g0,%g0,%o4 C save cy in register
221 subcc %g0,%o4,%g0 C restore cy
230 addx %g0,%g0,%o0 C return carry-out from most sign. limb
233 C If we come here, the alignment of s1_ptr and res_ptr as well as the
234 C alignment of s2_ptr and res_ptr differ. Since there are only two ways
235 C things can be aligned (that we care about) we now know that the alignment
236 C of s1_ptr and s2_ptr are the same.
241 andcc s1_ptr,4,%g0 C s1_ptr unaligned? Side effect: cy=0
242 be L(v2) C if no, branch
244 C Add least significant limb separately to align s1_ptr and s2_ptr
252 add res_ptr,4,res_ptr
254 L(v2): addx %g0,%g0,%o4 C save cy in register
257 subcc %g0,%o4,%g0 C restore cy
258 C Add blocks of 8 limbs until less than 8 limbs remain
284 addx %g0,%g0,%o4 C save cy in register
288 add res_ptr,32,res_ptr
290 subcc %g0,%o4,%g0 C restore cy
295 subcc %g0,%o4,%g0 C restore cy
303 addx %g0,%g0,%o4 C save cy in register
307 add res_ptr,8,res_ptr
309 subcc %g0,%o4,%g0 C restore cy
313 subcc %g0,%o4,%g0 C restore cy
323 addx %g0,%g0,%o0 C return carry-out from most sign. limb