Reorganisation of the source tree
[ghc-hetmet.git] / rts / gmp / mpn / arm / add_n.S
1 @ ARM mpn_add -- Add two limb vectors of the same length > 0 and store sum in
2 @ a third limb vector.
3 @ Contributed by Robert Harley.
4
5 @ Copyright (C) 1997, 2000 Free Software Foundation, Inc.
6
7 @ This file is part of the GNU MP Library.
8
9 @ The GNU MP Library is free software; you can redistribute it and/or modify
10 @ it under the terms of the GNU Lesser General Public License as published by
11 @ the Free Software Foundation; either version 2.1 of the License, or (at your
12 @ option) any later version.
13
14 @ The GNU MP Library is distributed in the hope that it will be useful, but
15 @ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 @ or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17 @ License for more details.
18
19 @ You should have received a copy of the GNU Lesser General Public License
20 @ along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
21 @ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 @ MA 02111-1307, USA.
23
24 #define s r0
25 #define a r1
26 #define b r2
27 #define n r3
28
29 #define sl r10
30 #define fp r11
31 #define ip r12
32 #define sp r13
33 #define lr r14
34 #define pc r15
35
36 .text
37         .align  0
38         .global __gmpn_add_n
39         .type   __gmpn_add_n,%function
40 __gmpn_add_n:
41         stmfd   sp!, { r8, r9, lr }
42         movs    n, n, lsr #1
43         bcc     skip1
44         ldr     ip, [a], #4
45         ldr     lr, [b], #4
46         adds    ip, ip, lr
47         str     ip, [s], #4
48 skip1:
49         tst     n, #1
50         beq     skip2
51         ldmia   a!, { r8, r9 }
52         ldmia   b!, { ip, lr }
53         adcs    r8, r8, ip
54         adcs    r9, r9, lr
55         stmia   s!, { r8, r9 }
56 skip2:
57         bics    n, n, #1
58         beq     return
59         stmfd   sp!, { r4, r5, r6, r7 }
60 add_n_loop:
61         ldmia   a!, { r4, r5, r6, r7 }
62         ldmia   b!, { r8, r9, ip, lr }
63         adcs    r4, r4, r8
64         ldr     r8, [s] /* Bring stuff into cache. */
65         adcs    r5, r5, r9
66         adcs    r6, r6, ip
67         adcs    r7, r7, lr
68         stmia   s!, { r4, r5, r6, r7 }
69         sub     n, n, #2
70         teq     n, #0
71         bne     add_n_loop
72         ldmfd   sp!, { r4, r5, r6, r7 }
73 return:
74         adc     r0, n, #0
75         ldmfd   sp!, { r8, r9, pc }
76 end:
77         .size   __gmpn_add_n, end - __gmpn_add_n