1/* mips3  add_n -- Add two limb vectors of the same length > 0 and store
2 *		   sum in a third limb vector.
3 *
4 *      Copyright (C) 1995, 1998, 2000
5 *                    2001, 2002 Free Software Foundation, Inc.
6 *
7 * This file is part of Libgcrypt.
8 *
9 * Libgcrypt is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
13 *
14 * Libgcrypt is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 */
23
24
25/*******************
26 *  mpi_limb_t
27 *  _gcry_mpih_add_n( mpi_ptr_t res_ptr,	($4)
28 *		   mpi_ptr_t s1_ptr,	($5)
29 *		   mpi_ptr_t s2_ptr,	($6)
30 *		   mpi_size_t size)	($7)
31 */
32
33	.text
34	.align	2
35	.globl	_gcry_mpih_add_n
36	.ent	_gcry_mpih_add_n
37_gcry_mpih_add_n:
38	.set	noreorder
39	.set	nomacro
40
41	ld	$10,0($5)
42	ld	$11,0($6)
43
44	daddiu	$7,$7,-1
45	and	$9,$7,4-1	# number of limbs in first loop
46	beq	$9,$0,.L0	# if multiple of 4 limbs, skip first loop
47	 move	$2,$0
48
49	dsubu	$7,$7,$9
50
51.Loop0: daddiu	$9,$9,-1
52	ld	$12,8($5)
53	daddu	$11,$11,$2
54	ld	$13,8($6)
55	sltu	$8,$11,$2
56	daddu	$11,$10,$11
57	sltu	$2,$11,$10
58	sd	$11,0($4)
59	or	$2,$2,$8
60
61	daddiu	$5,$5,8
62	daddiu	$6,$6,8
63	move	$10,$12
64	move	$11,$13
65	bne	$9,$0,.Loop0
66	 daddiu $4,$4,8
67
68.L0:	beq	$7,$0,.Lend
69	 nop
70
71.Loop:	daddiu	$7,$7,-4
72
73	ld	$12,8($5)
74	daddu	$11,$11,$2
75	ld	$13,8($6)
76	sltu	$8,$11,$2
77	daddu	$11,$10,$11
78	sltu	$2,$11,$10
79	sd	$11,0($4)
80	or	$2,$2,$8
81
82	ld	$10,16($5)
83	daddu	$13,$13,$2
84	ld	$11,16($6)
85	sltu	$8,$13,$2
86	daddu	$13,$12,$13
87	sltu	$2,$13,$12
88	sd	$13,8($4)
89	or	$2,$2,$8
90
91	ld	$12,24($5)
92	daddu	$11,$11,$2
93	ld	$13,24($6)
94	sltu	$8,$11,$2
95	daddu	$11,$10,$11
96	sltu	$2,$11,$10
97	sd	$11,16($4)
98	or	$2,$2,$8
99
100	ld	$10,32($5)
101	daddu	$13,$13,$2
102	ld	$11,32($6)
103	sltu	$8,$13,$2
104	daddu	$13,$12,$13
105	sltu	$2,$13,$12
106	sd	$13,24($4)
107	or	$2,$2,$8
108
109	daddiu	$5,$5,32
110	daddiu	$6,$6,32
111
112	bne	$7,$0,.Loop
113	 daddiu $4,$4,32
114
115.Lend:	daddu	$11,$11,$2
116	sltu	$8,$11,$2
117	daddu	$11,$10,$11
118	sltu	$2,$11,$10
119	sd	$11,0($4)
120	j	$31
121	or	$2,$2,$8
122
123	.end	_gcry_mpih_add_n
124
125