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 (C) 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 2.1 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; see the file COPYING.LIB. If not, write to
20 dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 dnl MA 02111-1307, USA.
24 include(`../config.m4')
34 xor s2_ptr,res_ptr,%g1
36 bne L(1) C branch if alignment differs
39 andcc res_ptr,4,%g0 C res_ptr unaligned? Side effect: cy=0
40 be L(v1) C if no, branch
42 C Add least significant limb separately to align res_ptr and s2_ptr
51 L(v1): addx %g0,%g0,%o4 C save cy in register
52 cmp n,2 C if n < 2 ...
53 bl L(end2) C ... branch to tail code
54 subcc %g0,%o4,%g0 C restore cy
61 subcc %g0,%o4,%g0 C restore cy
62 C Add blocks of 8 limbs until less than 8 limbs remain
88 addx %g0,%g0,%o4 C save cy in register
92 add res_ptr,32,res_ptr
94 subcc %g0,%o4,%g0 C restore cy
99 subcc %g0,%o4,%g0 C restore cy
100 C Add blocks of 2 limbs until less than 2 limbs remain
108 addx %g0,%g0,%o4 C save cy in register
112 add res_ptr,8,res_ptr
114 subcc %g0,%o4,%g0 C restore cy
119 addx %g0,%g0,%o4 C save cy in register
123 subcc %g0,%o4,%g0 C restore cy
132 addx %g0,%g0,%o0 C return carry-out from most sign. limb
134 L(1): xor s1_ptr,res_ptr,%g1
139 andcc res_ptr,4,%g0 C res_ptr unaligned? Side effect: cy=0
140 be L(v1b) C if no, branch
142 C Add least significant limb separately to align res_ptr and s1_ptr
150 add res_ptr,4,res_ptr
151 L(v1b): addx %g0,%g0,%o4 C save cy in register
152 cmp n,2 C if n < 2 ...
153 bl L(end2) C ... branch to tail code
154 subcc %g0,%o4,%g0 C restore cy
161 subcc %g0,%o4,%g0 C restore cy
162 C Add blocks of 8 limbs until less than 8 limbs remain
188 addx %g0,%g0,%o4 C save cy in register
192 add res_ptr,32,res_ptr
194 subcc %g0,%o4,%g0 C restore cy
199 subcc %g0,%o4,%g0 C restore cy
200 C Add blocks of 2 limbs until less than 2 limbs remain
208 addx %g0,%g0,%o4 C save cy in register
212 add res_ptr,8,res_ptr
214 subcc %g0,%o4,%g0 C restore cy
219 addx %g0,%g0,%o4 C save cy in register
223 subcc %g0,%o4,%g0 C restore cy
232 addx %g0,%g0,%o0 C return carry-out from most sign. limb
235 C If we come here, the alignment of s1_ptr and res_ptr as well as the
236 C alignment of s2_ptr and res_ptr differ. Since there are only two ways
237 C things can be aligned (that we care about) we now know that the alignment
238 C of s1_ptr and s2_ptr are the same.
243 andcc s1_ptr,4,%g0 C s1_ptr unaligned? Side effect: cy=0
244 be L(v2) C if no, branch
246 C Add least significant limb separately to align s1_ptr and s2_ptr
254 add res_ptr,4,res_ptr
256 L(v2): addx %g0,%g0,%o4 C save cy in register
259 subcc %g0,%o4,%g0 C restore cy
260 C Add blocks of 8 limbs until less than 8 limbs remain
286 addx %g0,%g0,%o4 C save cy in register
290 add res_ptr,32,res_ptr
292 subcc %g0,%o4,%g0 C restore cy
297 subcc %g0,%o4,%g0 C restore cy
305 addx %g0,%g0,%o4 C save cy in register
309 add res_ptr,8,res_ptr
311 subcc %g0,%o4,%g0 C restore cy
315 subcc %g0,%o4,%g0 C restore cy
325 addx %g0,%g0,%o0 C return carry-out from most sign. limb