github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/power/add_n.asm (about)

     1  dnl  IBM POWER mpn_add_n -- Add two limb vectors of equal, non-zero length.
     2  
     3  dnl  Copyright 1992, 1994-1996, 1999-2001, 2005 Free Software Foundation, Inc.
     4  
     5  dnl  This file is part of the GNU MP Library.
     6  dnl
     7  dnl  The GNU MP Library is free software; you can redistribute it and/or modify
     8  dnl  it under the terms of either:
     9  dnl
    10  dnl    * the GNU Lesser General Public License as published by the Free
    11  dnl      Software Foundation; either version 3 of the License, or (at your
    12  dnl      option) any later version.
    13  dnl
    14  dnl  or
    15  dnl
    16  dnl    * the GNU General Public License as published by the Free Software
    17  dnl      Foundation; either version 2 of the License, or (at your option) any
    18  dnl      later version.
    19  dnl
    20  dnl  or both in parallel, as here.
    21  dnl
    22  dnl  The GNU MP Library is distributed in the hope that it will be useful, but
    23  dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    24  dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    25  dnl  for more details.
    26  dnl
    27  dnl  You should have received copies of the GNU General Public License and the
    28  dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
    29  dnl  see https://www.gnu.org/licenses/.
    30  
    31  
    32  dnl  INPUT PARAMETERS
    33  dnl  res_ptr	r3
    34  dnl  s1_ptr	r4
    35  dnl  s2_ptr	r5
    36  dnl  size	r6
    37  
    38  include(`../config.m4')
    39  
    40  ASM_START()
    41  PROLOGUE(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  
    51  C 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  
    58  C We added least significant limbs.  Now reload the next limbs to enter loop.
    59  L1:	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
    63  Leven:	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  
    67  Loop:	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  
    77  Lend:	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
    83  EPILOGUE(mpn_add_n)