xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/thumb/add_n.asm (revision fdd524d4ccd2bb0c6f67401e938dabf773eb0372)
1dnl  ARM/Thumb mpn_add_n.
2
3dnl  Copyright 1997, 2000, 2012 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of the GNU Lesser General Public License as published by
9dnl  the Free Software Foundation; either version 3 of the License, or (at your
10dnl  option) any later version.
11
12dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15dnl  License for more details.
16
17dnl  You should have received a copy of the GNU Lesser General Public License
18dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20include(`../config.m4')
21
22C INPUT PARAMETERS
23define(`rp',	r0)
24define(`up',	r1)
25define(`vp',	r2)
26define(`n',	r3)
27
28ASM_START()
29	.thumb
30PROLOGUE(mpn_add_nc)
31	push	{r4, r5, r6}
32	ldr	r6, [sp, #12]		C init carry save register
33	sub	r6, #1
34	b	L(top)
35EPILOGUE()
36PROLOGUE(mpn_add_n)
37	push	{r4, r5, r6}
38	neg	r6, n			C init carry save register
39
40L(top):	ldmia	up!, {r4}		C load next limb from S1
41	cmp	n, r6			C tricky carry restore
42	ldmia	vp!, {r5}		C load next limb from S2
43	adc	r4, r5
44	stmia	rp!, {r4}		C store result limb to RES
45	sbc	r6, r6			C save negated carry
46	sub	n, #1
47	bne	L(top)
48
49	add	r0, r6, #1
50	pop	{r4, r5, r6}
51	bx	lr
52EPILOGUE()
53