Rewritten.
[glibc.git] / sysdeps / rs6000 / add_n.s
blob7090cf1b004358fe068bb531764f332ed4e850ec
1 # IBM POWER __mpn_add_n -- Add two limb vectors of equal, non-zero length.
3 # Copyright (C) 1992, 1994 Free Software Foundation, Inc.
5 # This file is part of the GNU MP Library.
7 # The GNU MP Library is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Library General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or (at your
10 # option) any later version.
12 # The GNU MP Library is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 # License for more details.
17 # You should have received a copy of the GNU Library General Public License
18 # along with the GNU MP Library; see the file COPYING.LIB. If not, write to
19 # the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 # INPUT PARAMETERS
23 # res_ptr r3
24 # s1_ptr r4
25 # s2_ptr r5
26 # size r6
28 .toc
29 .extern __mpn_add_n[DS]
30 .extern .__mpn_add_n
31 .csect [PR]
32 .align 2
33 .globl __mpn_add_n
34 .globl .__mpn_add_n
35 .csect __mpn_add_n[DS]
36 __mpn_add_n:
37 .long .__mpn_add_n, TOC[tc0], 0
38 .csect [PR]
39 .__mpn_add_n:
40 mtctr 6 # copy size into CTR
41 l 8,0(4) # load least significant s1 limb
42 l 0,0(5) # load least significant s2 limb
43 cal 3,-4(3) # offset res_ptr, it's updated before used
44 a 7,0,8 # add least significant limbs, set cy
45 bdz Lend # If done, skip loop
46 Loop: lu 8,4(4) # load s1 limb and update s1_ptr
47 lu 0,4(5) # load s2 limb and update s2_ptr
48 stu 7,4(3) # store previous limb in load latency slot
49 ae 7,0,8 # add new limbs with cy, set cy
50 bdn Loop # decrement CTR and loop back
51 Lend: st 7,4(3) # store ultimate result limb
52 lil 3,0 # load cy into ...
53 aze 3,3 # ... return value register