1dnl IBM POWER mpn_add_n -- Add two limb vectors of equal, non-zero length. 2 3dnl Copyright 1992, 1994-1996, 1999-2001, 2005 Free Software Foundation, Inc. 4 5dnl This file is part of the GNU MP Library. 6dnl 7dnl The GNU MP Library is free software; you can redistribute it and/or modify 8dnl it under the terms of either: 9dnl 10dnl * the GNU Lesser General Public License as published by the Free 11dnl Software Foundation; either version 3 of the License, or (at your 12dnl option) any later version. 13dnl 14dnl or 15dnl 16dnl * the GNU General Public License as published by the Free Software 17dnl Foundation; either version 2 of the License, or (at your option) any 18dnl later version. 19dnl 20dnl or both in parallel, as here. 21dnl 22dnl The GNU MP Library is distributed in the hope that it will be useful, but 23dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 24dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25dnl for more details. 26dnl 27dnl You should have received copies of the GNU General Public License and the 28dnl GNU Lesser General Public License along with the GNU MP Library. If not, 29dnl see https://www.gnu.org/licenses/. 30 31 32dnl INPUT PARAMETERS 33dnl res_ptr r3 34dnl s1_ptr r4 35dnl s2_ptr r5 36dnl size r6 37 38include(`../config.m4') 39 40ASM_START() 41PROLOGUE(mpn_add_n) 42 andil. 10,6,1 C odd or even number of limbs? 43 l 8,0(4) C load least significant s1 limb 44 l 0,0(5) C load least significant s2 limb 45 cal 3,-4(3) C offset res_ptr, it's updated before it's used 46 sri 10,6,1 C count for unrolled loop 47 a 7,0,8 C add least significant limbs, set cy 48 mtctr 10 C copy count into CTR 49 beq 0,Leven C branch if even # of limbs (# of limbs >= 2) 50 51C We have an odd # of limbs. Add the first limbs separately. 52 cmpi 1,10,0 C is count for unrolled loop zero? 53 bc 4,6,L1 C bne cr1,L1 (misassembled by gas) 54 st 7,4(3) 55 aze 3,10 C use the fact that r10 is zero... 56 br C return 57 58C We added least significant limbs. Now reload the next limbs to enter loop. 59L1: lu 8,4(4) C load s1 limb and update s1_ptr 60 lu 0,4(5) C load s2 limb and update s2_ptr 61 stu 7,4(3) 62 ae 7,0,8 C add limbs, set cy 63Leven: lu 9,4(4) C load s1 limb and update s1_ptr 64 lu 10,4(5) C load s2 limb and update s2_ptr 65 bdz Lend C If done, skip loop 66 67Loop: lu 8,4(4) C load s1 limb and update s1_ptr 68 lu 0,4(5) C load s2 limb and update s2_ptr 69 ae 11,10,9 C add previous limbs with cy, set cy 70 stu 7,4(3) C 71 lu 9,4(4) C load s1 limb and update s1_ptr 72 lu 10,4(5) C load s2 limb and update s2_ptr 73 ae 7,0,8 C add previous limbs with cy, set cy 74 stu 11,4(3) C 75 bdn Loop C decrement CTR and loop back 76 77Lend: ae 11,10,9 C add limbs with cy, set cy 78 st 7,4(3) C 79 st 11,8(3) C 80 lil 3,0 C load cy into ... 81 aze 3,3 C ... return value register 82 br 83EPILOGUE(mpn_add_n) 84