1101704Smjacobdnl  MIPS32 mpn_addmul_1 -- Multiply a limb vector with a single limb and add
2139749Simpdnl  the product to a second limb vector.
3101704Smjacob
4101704Smjacobdnl  Copyright 1992, 1994, 1996, 2000, 2002 Free Software Foundation, Inc.
5101704Smjacob
6101704Smjacobdnl  This file is part of the GNU MP Library.
7101704Smjacob
8101704Smjacobdnl  The GNU MP Library is free software; you can redistribute it and/or modify
9101704Smjacobdnl  it under the terms of the GNU Lesser General Public License as published
10101704Smjacobdnl  by the Free Software Foundation; either version 3 of the License, or (at
11101704Smjacobdnl  your option) any later version.
12101704Smjacob
13101704Smjacobdnl  The GNU MP Library is distributed in the hope that it will be useful, but
14101704Smjacobdnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15101704Smjacobdnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16101704Smjacobdnl  License for more details.
17101704Smjacob
18101704Smjacobdnl  You should have received a copy of the GNU Lesser General Public License
19101704Smjacobdnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20101704Smjacob
21101704Smjacobinclude(`../config.m4')
22101704Smjacob
23101704SmjacobC INPUT PARAMETERS
24101704SmjacobC res_ptr	$4
25101704SmjacobC s1_ptr	$5
26101704SmjacobC size		$6
27101704SmjacobC s2_limb	$7
28156000Smjacob
29156000SmjacobASM_START()
30156000SmjacobPROLOGUE(mpn_addmul_1)
31156000Smjacob
32156000SmjacobC feed-in phase 0
33156000Smjacob	lw	$8,0($5)
34156000Smjacob
35156000SmjacobC feed-in phase 1
36156000Smjacob	addiu	$5,$5,4
37156000Smjacob	multu	$8,$7
38156000Smjacob
39156000Smjacob	addiu	$6,$6,-1
40156000Smjacob	beq	$6,$0,$LC0
41156000Smjacob	 move	$2,$0		C zero cy2
42156000Smjacob
43156000Smjacob	addiu	$6,$6,-1
44156000Smjacob	beq	$6,$0,$LC1
45156000Smjacob	lw	$8,0($5)	C load new s1 limb as early as possible
46156000Smjacob
47156000SmjacobLoop:	lw	$10,0($4)
48156000Smjacob	mflo	$3
49156000Smjacob	mfhi	$9
50156000Smjacob	addiu	$5,$5,4
51156000Smjacob	addu	$3,$3,$2	C add old carry limb to low product limb
52156000Smjacob	multu	$8,$7
53156000Smjacob	lw	$8,0($5)	C load new s1 limb as early as possible
54156000Smjacob	addiu	$6,$6,-1	C decrement loop counter
55156000Smjacob	sltu	$2,$3,$2	C carry from previous addition -> $2
56156000Smjacob	addu	$3,$10,$3
57156000Smjacob	sltu	$10,$3,$10
58147883Sscottl	addu	$2,$2,$10
59156000Smjacob	sw	$3,0($4)
60156000Smjacob	addiu	$4,$4,4
61159052Smjacob	bne	$6,$0,Loop
62159052Smjacob	 addu	$2,$9,$2	C add high product limb and carry from addition
63159052Smjacob
64159052SmjacobC wind-down phase 1
65101704Smjacob$LC1:	lw	$10,0($4)
66101704Smjacob	mflo	$3
67147883Sscottl	mfhi	$9
68147883Sscottl	addu	$3,$3,$2
69147883Sscottl	sltu	$2,$3,$2
70147883Sscottl	multu	$8,$7
71147883Sscottl	addu	$3,$10,$3
72147883Sscottl	sltu	$10,$3,$10
73147883Sscottl	addu	$2,$2,$10
74147883Sscottl	sw	$3,0($4)
75147883Sscottl	addiu	$4,$4,4
76147883Sscottl	addu	$2,$9,$2	C add high product limb and carry from addition
77147883Sscottl
78147883SscottlC wind-down phase 0
79147883Sscottl$LC0:	lw	$10,0($4)
80147883Sscottl	mflo	$3
81147883Sscottl	mfhi	$9
82148679Sgibbs	addu	$3,$3,$2
83148679Sgibbs	sltu	$2,$3,$2
84148679Sgibbs	addu	$3,$10,$3
85147883Sscottl	sltu	$10,$3,$10
86147883Sscottl	addu	$2,$2,$10
87147883Sscottl	sw	$3,0($4)
88147883Sscottl	j	$31
89147883Sscottl	addu	$2,$9,$2	C add high product limb and carry from addition
90147883SscottlEPILOGUE(mpn_addmul_1)
91147883Sscottl