xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/pa32/hppa2_0/add_n.asm (revision 6a493d6bc668897c91594964a732d38505b70cbb)
1dnl  HP-PA 2.0 32-bit mpn_add_n -- Add two limb vectors of the same length > 0
2dnl  and store sum in a third limb vector.
3
4dnl  Copyright 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
5
6dnl  This file is part of the GNU MP Library.
7
8dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9dnl  it under the terms of the GNU Lesser General Public License as published
10dnl  by the Free Software Foundation; either version 3 of the License, or (at
11dnl  your option) any later version.
12
13dnl  The GNU MP Library is distributed in the hope that it will be useful, but
14dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16dnl  License for more details.
17
18dnl  You should have received a copy of the GNU Lesser General Public License
19dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21include(`../config.m4')
22
23C INPUT PARAMETERS
24C res_ptr	gr26
25C s1_ptr	gr25
26C s2_ptr	gr24
27C size		gr23
28
29C This runs at 2 cycles/limb on PA8000.
30
31ASM_START()
32PROLOGUE(mpn_add_n)
33	sub		%r0,%r23,%r22
34	zdep		%r22,30,3,%r28		C r28 = 2 * (-n & 7)
35	zdep		%r22,29,3,%r22		C r22 = 4 * (-n & 7)
36	sub		%r25,%r22,%r25		C offset s1_ptr
37	sub		%r24,%r22,%r24		C offset s2_ptr
38	sub		%r26,%r22,%r26		C offset res_ptr
39	blr		%r28,%r0		C branch into loop
40	add		%r0,%r0,%r0		C reset carry
41
42LDEF(loop)
43	ldw		0(%r25),%r20
44	ldw		0(%r24),%r31
45	addc		%r20,%r31,%r20
46	stw		%r20,0(%r26)
47
48LDEF(7)
49	ldw		4(%r25),%r21
50	ldw		4(%r24),%r19
51	addc		%r21,%r19,%r21
52	stw		%r21,4(%r26)
53
54LDEF(6)
55	ldw		8(%r25),%r20
56	ldw		8(%r24),%r31
57	addc		%r20,%r31,%r20
58	stw		%r20,8(%r26)
59
60LDEF(5)
61	ldw		12(%r25),%r21
62	ldw		12(%r24),%r19
63	addc		%r21,%r19,%r21
64	stw		%r21,12(%r26)
65
66LDEF(4)
67	ldw		16(%r25),%r20
68	ldw		16(%r24),%r31
69	addc		%r20,%r31,%r20
70	stw		%r20,16(%r26)
71
72LDEF(3)
73	ldw		20(%r25),%r21
74	ldw		20(%r24),%r19
75	addc		%r21,%r19,%r21
76	stw		%r21,20(%r26)
77
78LDEF(2)
79	ldw		24(%r25),%r20
80	ldw		24(%r24),%r31
81	addc		%r20,%r31,%r20
82	stw		%r20,24(%r26)
83
84LDEF(1)
85	ldw		28(%r25),%r21
86	ldo		32(%r25),%r25
87	ldw		28(%r24),%r19
88	addc		%r21,%r19,%r21
89	stw		%r21,28(%r26)
90	ldo		32(%r24),%r24
91	addib,>		-8,%r23,L(loop)
92	ldo		32(%r26),%r26
93
94	bv		(%r2)
95	addc		%r0,%r0,%r28
96EPILOGUE()
97