|
Packit |
6c4009 |
/* Add two limb vectors of the same length > 0 and store sum in a third
|
|
Packit |
6c4009 |
limb vector.
|
|
Packit |
6c4009 |
Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
|
|
Packit |
6c4009 |
This file is part of the GNU MP Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU MP Library is free software; you can redistribute it and/or modify
|
|
Packit |
6c4009 |
it under the terms of the GNU Lesser General Public License as published by
|
|
Packit |
6c4009 |
the Free Software Foundation; either version 2.1 of the License, or (at your
|
|
Packit |
6c4009 |
option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU MP Library is distributed in the hope that it will be useful, but
|
|
Packit |
6c4009 |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit |
6c4009 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
Packit |
6c4009 |
License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
6c4009 |
along with the GNU MP Library; see the file COPYING.LIB. If not,
|
|
Packit |
6c4009 |
see <http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/*
|
|
Packit |
6c4009 |
INPUT PARAMETERS
|
|
Packit |
6c4009 |
res_ptr %r2
|
|
Packit |
6c4009 |
s1_ptr %r3
|
|
Packit |
6c4009 |
s2_ptr %r4
|
|
Packit |
6c4009 |
size %r5
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include "sysdep.h"
|
|
Packit |
6c4009 |
#include "asm-syntax.h"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
ENTRY(__mpn_add_n)
|
|
Packit |
6c4009 |
stg %r6,48(%r15) # save register 6
|
|
Packit |
6c4009 |
cfi_offset (%r6,-112)
|
|
Packit |
6c4009 |
slgr %r1,%r1
|
|
Packit |
6c4009 |
lghi %r0,1 # cannot use ahi to add carry, use alr
|
|
Packit |
6c4009 |
.L0: lg %r6,0(%r1,%r3) # .L0 -> no carry from last add
|
|
Packit |
6c4009 |
alg %r6,0(%r1,%r4)
|
|
Packit |
6c4009 |
stg %r6,0(%r1,%r2)
|
|
Packit |
6c4009 |
la %r1,8(%r1)
|
|
Packit |
6c4009 |
brc 3,.L3
|
|
Packit |
6c4009 |
.L1: brct %r5,.L0
|
|
Packit |
6c4009 |
slgr %r2,%r2 # no last carry to return
|
|
Packit |
6c4009 |
j .Lexit
|
|
Packit |
6c4009 |
.L2: lg %r6,0(%r1,%r3) # .L2 -> carry from last add
|
|
Packit |
6c4009 |
alg %r6,0(%r1,%r4)
|
|
Packit |
6c4009 |
brc 3,.L4
|
|
Packit |
6c4009 |
algr %r6,%r0 # no carry yet, add carry from last add
|
|
Packit |
6c4009 |
stg %r6,0(%r1,%r2)
|
|
Packit |
6c4009 |
la %r1,8(%r1)
|
|
Packit |
6c4009 |
brc 12,.L1 # new carry ?
|
|
Packit |
6c4009 |
.L3: brct %r5,.L2
|
|
Packit |
6c4009 |
lgr %r2,%r0 # return last carry
|
|
Packit |
6c4009 |
j .Lexit
|
|
Packit |
6c4009 |
.L4: algr %r6,%r0 # already a carry, add carry from last add
|
|
Packit |
6c4009 |
stg %r6,0(%r1,%r2)
|
|
Packit |
6c4009 |
la %r1,8(%r1)
|
|
Packit |
6c4009 |
brct %r5,.L2
|
|
Packit |
6c4009 |
lgr %r2,%r0 # return last carry
|
|
Packit |
6c4009 |
.Lexit: lg %r6,48(%r15) # restore register 6
|
|
Packit |
6c4009 |
br %r14
|
|
Packit |
6c4009 |
END(__mpn_add_n)
|