Upload Tizen:Base source
[external/gmp.git] / mpn / arm / add_n.asm
1 dnl  ARM mpn_add_n -- Add two limb vectors of the same length > 0 and store sum
2 dnl  in a third limb vector.
3 dnl  Contributed by Robert Harley.
4
5 dnl  Copyright 1997, 2000, 2001 Free Software Foundation, Inc.
6
7 dnl  This file is part of the GNU MP Library.
8
9 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl  it under the terms of the GNU Lesser General Public License as published
11 dnl  by the Free Software Foundation; either version 3 of the License, or (at
12 dnl  your option) any later version.
13
14 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
15 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17 dnl  License for more details.
18
19 dnl  You should have received a copy of the GNU Lesser General Public License
20 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
21
22 include(`../config.m4')
23
24 C This code runs at 5 cycles/limb.
25
26 define(`rp',`r0')
27 define(`up',`r1')
28 define(`vp',`r2')
29 define(`n',`r3')
30
31
32 ASM_START()
33 PROLOGUE(mpn_add_n)
34         stmfd   sp!, { r8, r9, lr }
35         movs    n, n, lsr #1
36         bcc     L(skip1)
37         ldr     r12, [up], #4
38         ldr     lr, [vp], #4
39         adds    r12, r12, lr
40         str     r12, [rp], #4
41 L(skip1):
42         tst     n, #1
43         beq     L(skip2)
44         ldmia   up!, { r8, r9 }
45         ldmia   vp!, { r12, lr }
46         adcs    r8, r8, r12
47         adcs    r9, r9, lr
48         stmia   rp!, { r8, r9 }
49 L(skip2):
50         bics    n, n, #1
51         beq     L(return)
52         stmfd   sp!, { r4, r5, r6, r7 }
53 L(add_n_loop):
54         ldmia   up!, { r4, r5, r6, r7 }
55         ldmia   vp!, { r8, r9, r12, lr }
56         adcs    r4, r4, r8
57         ldr     r8, [rp, #12]                   C cache allocate
58         adcs    r5, r5, r9
59         adcs    r6, r6, r12
60         adcs    r7, r7, lr
61         stmia   rp!, { r4, r5, r6, r7 }
62         sub     n, n, #2
63         teq     n, #0
64         bne     L(add_n_loop)
65         ldmfd   sp!, { r4, r5, r6, r7 }
66 L(return):
67         adc     r0, n, #0
68         ldmfd   sp!, { r8, r9, pc }
69 EPILOGUE(mpn_add_n)