1/* mips3  sub_n -- Subtract two limb vectors of the same length > 0 and
2 *		  store difference in a third limb vector.
3 *
4 *      Copyright (C) 1995, 1998, 1999, 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_sub_n( mpi_ptr_t res_ptr,	(r4)
28 *		   mpi_ptr_t s1_ptr,	(r5)
29 *		   mpi_ptr_t s2_ptr,	(r6)
30 *		   mpi_size_t size)	(r7)
31 */
32
33
34	.text
35	.align	2
36	.globl	_gcry_mpih_sub_n
37	.ent	_gcry_mpih_sub_n
38_gcry_mpih_sub_n:
39	.set	noreorder
40	.set	nomacro
41
42	ld	$10,0($5)
43	ld	$11,0($6)
44
45	daddiu	$7,$7,-1
46	and	$9,$7,4-1	# number of limbs in first loop
47	beq	$9,$0,.L0	# if multiple of 4 limbs, skip first loop
48	move   $2,$0
49
50	dsubu	$7,$7,$9
51
52.Loop0: daddiu	$9,$9,-1
53	ld	$12,8($5)
54	daddu	$11,$11,$2
55	ld	$13,8($6)
56	sltu	$8,$11,$2
57	dsubu	$11,$10,$11
58	sltu	$2,$10,$11
59	sd	$11,0($4)
60	or	$2,$2,$8
61
62	daddiu	$5,$5,8
63	daddiu	$6,$6,8
64	move	$10,$12
65	move	$11,$13
66	bne	$9,$0,.Loop0
67	 daddiu $4,$4,8
68
69.L0:	beq	$7,$0,.Lend
70	 nop
71
72.Loop:	daddiu	$7,$7,-4
73
74	ld	$12,8($5)
75	daddu	$11,$11,$2
76	ld	$13,8($6)
77	sltu	$8,$11,$2
78	dsubu	$11,$10,$11
79	sltu	$2,$10,$11
80	sd	$11,0($4)
81	or	$2,$2,$8
82
83	ld	$10,16($5)
84	daddu	$13,$13,$2
85	ld	$11,16($6)
86	sltu	$8,$13,$2
87	dsubu	$13,$12,$13
88	sltu	$2,$12,$13
89	sd	$13,8($4)
90	or	$2,$2,$8
91
92	ld	$12,24($5)
93	daddu	$11,$11,$2
94	ld	$13,24($6)
95	sltu	$8,$11,$2
96	dsubu	$11,$10,$11
97	sltu	$2,$10,$11
98	sd	$11,16($4)
99	or	$2,$2,$8
100
101	ld	$10,32($5)
102	daddu	$13,$13,$2
103	ld	$11,32($6)
104	sltu	$8,$13,$2
105	dsubu	$13,$12,$13
106	sltu	$2,$12,$13
107	sd	$13,24($4)
108	or	$2,$2,$8
109
110	daddiu	$5,$5,32
111	daddiu	$6,$6,32
112
113	bne	$7,$0,.Loop
114	 daddiu $4,$4,32
115
116.Lend:	daddu	$11,$11,$2
117	sltu	$8,$11,$2
118	dsubu	$11,$10,$11
119	sltu	$2,$10,$11
120	sd	$11,0($4)
121	j	$31
122	or	$2,$2,$8
123
124	.end	_gcry_mpih_sub_n
125
126