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