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