1dnl  MIPS32 mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
2dnl  store difference 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_sub_n)
42	lw	$10,0($5)
43	lw	$11,0($6)
44
45	addiu	$7,$7,-1
46	and	$9,$7,4-1	C number of limbs in first loop
47	beq	$9,$0,.L0	C if multiple of 4 limbs, skip first loop
48	 move	$2,$0
49
50	subu	$7,$7,$9
51
52.Loop0:	addiu	$9,$9,-1
53	lw	$12,4($5)
54	addu	$11,$11,$2
55	lw	$13,4($6)
56	sltu	$8,$11,$2
57	subu	$11,$10,$11
58	sltu	$2,$10,$11
59	sw	$11,0($4)
60	or	$2,$2,$8
61
62	addiu	$5,$5,4
63	addiu	$6,$6,4
64	move	$10,$12
65	move	$11,$13
66	bne	$9,$0,.Loop0
67	 addiu	$4,$4,4
68
69.L0:	beq	$7,$0,.Lend
70	 nop
71
72.Loop:	addiu	$7,$7,-4
73
74	lw	$12,4($5)
75	addu	$11,$11,$2
76	lw	$13,4($6)
77	sltu	$8,$11,$2
78	subu	$11,$10,$11
79	sltu	$2,$10,$11
80	sw	$11,0($4)
81	or	$2,$2,$8
82
83	lw	$10,8($5)
84	addu	$13,$13,$2
85	lw	$11,8($6)
86	sltu	$8,$13,$2
87	subu	$13,$12,$13
88	sltu	$2,$12,$13
89	sw	$13,4($4)
90	or	$2,$2,$8
91
92	lw	$12,12($5)
93	addu	$11,$11,$2
94	lw	$13,12($6)
95	sltu	$8,$11,$2
96	subu	$11,$10,$11
97	sltu	$2,$10,$11
98	sw	$11,8($4)
99	or	$2,$2,$8
100
101	lw	$10,16($5)
102	addu	$13,$13,$2
103	lw	$11,16($6)
104	sltu	$8,$13,$2
105	subu	$13,$12,$13
106	sltu	$2,$12,$13
107	sw	$13,12($4)
108	or	$2,$2,$8
109
110	addiu	$5,$5,16
111	addiu	$6,$6,16
112
113	bne	$7,$0,.Loop
114	 addiu	$4,$4,16
115
116.Lend:	addu	$11,$11,$2
117	sltu	$8,$11,$2
118	subu	$11,$10,$11
119	sltu	$2,$10,$11
120	sw	$11,0($4)
121	j	$31
122	or	$2,$2,$8
123EPILOGUE(mpn_sub_n)
124