1dnl  MIPS32 mpn_add_n -- Add two limb vectors of the same length > 0 and store
2dnl  sum in a third limb vector.
3
4dnl  Copyright 1995, 2000, 2002 Free Software Foundation, Inc.
5
6dnl  This file is part of the GNU MP Library.
7dnl
8dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9dnl  it under the terms of either:
10dnl
11dnl    * the GNU Lesser General Public License as published by the Free
12dnl      Software Foundation; either version 3 of the License, or (at your
13dnl      option) any later version.
14dnl
15dnl  or
16dnl
17dnl    * the GNU General Public License as published by the Free Software
18dnl      Foundation; either version 2 of the License, or (at your option) any
19dnl      later version.
20dnl
21dnl  or both in parallel, as here.
22dnl
23dnl  The GNU MP Library is distributed in the hope that it will be useful, but
24dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26dnl  for more details.
27dnl
28dnl  You should have received copies of the GNU General Public License and the
29dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
30dnl  see https://www.gnu.org/licenses/.
31
32include(`../config.m4')
33
34C INPUT PARAMETERS
35C res_ptr	$4
36C s1_ptr	$5
37C s2_ptr	$6
38C size		$7
39
40ASM_START()
41PROLOGUE(mpn_add_n)
42
43	lw	$10,0($5)
44	lw	$11,0($6)
45
46	addiu	$7,$7,-1
47	and	$9,$7,4-1	C number of limbs in first loop
48	beq	$9,$0,.L0	C if multiple of 4 limbs, skip first loop
49	 move	$2,$0
50
51	subu	$7,$7,$9
52
53.Loop0:	addiu	$9,$9,-1
54	lw	$12,4($5)
55	addu	$11,$11,$2
56	lw	$13,4($6)
57	sltu	$8,$11,$2
58	addu	$11,$10,$11
59	sltu	$2,$11,$10
60	sw	$11,0($4)
61	or	$2,$2,$8
62
63	addiu	$5,$5,4
64	addiu	$6,$6,4
65	move	$10,$12
66	move	$11,$13
67	bne	$9,$0,.Loop0
68	 addiu	$4,$4,4
69
70.L0:	beq	$7,$0,.Lend
71	 nop
72
73.Loop:	addiu	$7,$7,-4
74
75	lw	$12,4($5)
76	addu	$11,$11,$2
77	lw	$13,4($6)
78	sltu	$8,$11,$2
79	addu	$11,$10,$11
80	sltu	$2,$11,$10
81	sw	$11,0($4)
82	or	$2,$2,$8
83
84	lw	$10,8($5)
85	addu	$13,$13,$2
86	lw	$11,8($6)
87	sltu	$8,$13,$2
88	addu	$13,$12,$13
89	sltu	$2,$13,$12
90	sw	$13,4($4)
91	or	$2,$2,$8
92
93	lw	$12,12($5)
94	addu	$11,$11,$2
95	lw	$13,12($6)
96	sltu	$8,$11,$2
97	addu	$11,$10,$11
98	sltu	$2,$11,$10
99	sw	$11,8($4)
100	or	$2,$2,$8
101
102	lw	$10,16($5)
103	addu	$13,$13,$2
104	lw	$11,16($6)
105	sltu	$8,$13,$2
106	addu	$13,$12,$13
107	sltu	$2,$13,$12
108	sw	$13,12($4)
109	or	$2,$2,$8
110
111	addiu	$5,$5,16
112	addiu	$6,$6,16
113
114	bne	$7,$0,.Loop
115	 addiu	$4,$4,16
116
117.Lend:	addu	$11,$11,$2
118	sltu	$8,$11,$2
119	addu	$11,$10,$11
120	sltu	$2,$11,$10
121	sw	$11,0($4)
122	j	$31
123	or	$2,$2,$8
124EPILOGUE(mpn_add_n)
125