]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/sparc/sparc64/add_n.S
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / sparc / sparc64 / add_n.S
CommitLineData
5ae3e846
UD
1/* SPARC v9 __mpn_add_n -- Add two limb vectors of the same length > 0 and
2 store sum in a third limb vector.
9c84384c 3
2b778ceb 4 Copyright (C) 1995-2021 Free Software Foundation, Inc.
5ae3e846
UD
5
6 This file is part of the GNU MP Library.
7
8 The GNU MP Library is free software; you can redistribute it and/or modify
6d84f89a
AJ
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or (at your
5ae3e846
UD
11 option) any later version.
12
13 The GNU MP Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
6d84f89a 15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
5ae3e846
UD
16 License for more details.
17
6d84f89a 18 You should have received a copy of the GNU Lesser General Public License
59ba27a6 19 along with the GNU MP Library; see the file COPYING.LIB. If not,
5a82c748 20 see <https://www.gnu.org/licenses/>. */
5ae3e846
UD
21
22
23#include <sysdep.h>
24
25
26/* INPUT PARAMETERS
27 res_ptr %o0
28 s1_ptr %o1
29 s2_ptr %o2
30 size %o3 */
31
32
33ENTRY(__mpn_add_n)
34
8cb079d4 35 sub %g0,%o3,%g5
5ae3e846
UD
36 sllx %o3,3,%g1
37 add %o1,%g1,%o1 ! make s1_ptr point at end
38 add %o2,%g1,%o2 ! make s2_ptr point at end
39 add %o0,%g1,%o0 ! make res_ptr point at end
40 mov 0,%o4 ! clear carry variable
8cb079d4 41 sllx %g5,3,%o5 ! compute initial address index
5ae3e846
UD
42
431: ldx [%o2+%o5],%g1 ! load s2 limb
8cb079d4
UD
44 add %g5,1,%g5 ! increment loop count
45 ldx [%o1+%o5],%o3 ! load s1 limb
5ae3e846
UD
46 addcc %g1,%o4,%g1 ! add s2 limb and carry variable
47 movcc %xcc,0,%o4 ! if carry-out, o4 was 1; clear it
8cb079d4 48 addcc %g1,%o3,%g1 ! add s1 limb to sum
5ae3e846
UD
49 stx %g1,[%o0+%o5] ! store result
50 add %o5,8,%o5 ! increment address index
8cb079d4 51 brnz,pt %g5,1b
5ae3e846
UD
52 movcs %xcc,1,%o4 ! if s1 add gave carry, record it
53
54 retl
55 mov %o4,%o0
56
57END(__mpn_add_n)