1 ; mc88110 __gmpn_sub_n -- Subtract two limb vectors of the same length > 0 and
2 ; store difference in a third limb vector.
4 ; Copyright 1995, 1996, 2000 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 3 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. If not, see http://www.gnu.org/licenses/.
32 global C_SYMBOL_NAME(__gmpn_sub_n)
33 C_SYMBOL_NAME(__gmpn_sub_n):
34 subu.co r0,r0,r0 ; set cy flag
35 xor r12,s2_ptr,res_ptr
38 L0: bb0 2,res_ptr,L_v1 ; branch if res_ptr is aligned
39 /* Add least significant limb separately to align res_ptr and s2_ptr */
47 addu res_ptr,res_ptr,4
56 /* Add blocks of 8 limbs until less than 8 limbs remain */
58 Loop1: subu size,size,8
85 addu res_ptr,res_ptr,32
88 Lfin1: addu size,size,8-2
90 /* Add blocks of 2 limbs until less than 2 limbs remain */
91 Loope1: subu.cio r6,r10,r8
100 addu res_ptr,res_ptr,8
102 Lend1: subu.cio r6,r10,r8
113 Lret1: addu.ci r2,r0,r0 ; return carry-out from most sign. limb
117 L1: xor r12,s1_ptr,res_ptr
120 bb0 2,res_ptr,L_v1b ; branch if res_ptr is aligned
121 /* Add least significant limb separately to align res_ptr and s1_ptr */
129 addu res_ptr,res_ptr,4
130 L_v1b: cmp r12,size,2
138 /* Add blocks of 8 limbs until less than 8 limbs remain */
140 Loop1b: subu size,size,8
163 addu s2_ptr,s2_ptr,32
165 addu s1_ptr,s1_ptr,32
167 addu res_ptr,res_ptr,32
170 Lfin1b: addu size,size,8-2
172 /* Add blocks of 2 limbs until less than 2 limbs remain */
173 Loope1b:subu.cio r6,r8,r10
182 addu res_ptr,res_ptr,8
183 bcnd ge0,size,Loope1b
184 Lend1b: subu.cio r6,r8,r10
195 Lret1b: addu.ci r2,r0,r0 ; return carry-out from most sign. limb
200 /* If we come here, the alignment of s1_ptr and res_ptr as well as the
201 alignment of s2_ptr and res_ptr differ. Since there are only two ways
202 things can be aligned (that we care about) we now know that the alignment
203 of s1_ptr and s2_ptr are the same. */
207 bb0 2,s1_ptr,L_v2 ; branch if s1_ptr is aligned
208 /* Add least significant limb separately to align res_ptr and s2_ptr */
216 addu res_ptr,res_ptr,4
218 L_v2: subu size,size,8
220 /* Add blocks of 8 limbs until less than 8 limbs remain */
222 Loop2: subu size,size,8
247 addu s1_ptr,s1_ptr,32
248 addu s2_ptr,s2_ptr,32
249 addu res_ptr,res_ptr,32
252 Lfin2: addu size,size,8-2
254 Loope2: ld.d r8,s1_ptr,0
263 addu res_ptr,res_ptr,8
265 Lend2: bb0 0,size,Lret2
267 Ljone: ld r10,s1_ptr,0
272 Lret2: addu.ci r2,r0,r0 ; return carry-out from most sign. limb