1dnl  MIPS32 mpn_addmul_1 -- Multiply a limb vector with a single limb and add
2dnl  the product to a second limb vector.
3
4dnl  Copyright 1992, 1994, 1996, 2000, 2002 Free Software Foundation, Inc.
5
6dnl  This file is part of the GNU MP Library.
7
8dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9dnl  it under the terms of the GNU Lesser General Public License as published
10dnl  by the Free Software Foundation; either version 3 of the License, or (at
11dnl  your option) any later version.
12
13dnl  The GNU MP Library is distributed in the hope that it will be useful, but
14dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16dnl  License for more details.
17
18dnl  You should have received a copy of the GNU Lesser General Public License
19dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21include(`../config.m4')
22
23C INPUT PARAMETERS
24C res_ptr	$4
25C s1_ptr	$5
26C size		$6
27C s2_limb	$7
28
29ASM_START()
30PROLOGUE(mpn_addmul_1)
31
32C feed-in phase 0
33	lw	$8,0($5)
34
35C feed-in phase 1
36	addiu	$5,$5,4
37	multu	$8,$7
38
39	addiu	$6,$6,-1
40	beq	$6,$0,$LC0
41	 move	$2,$0		C zero cy2
42
43	addiu	$6,$6,-1
44	beq	$6,$0,$LC1
45	lw	$8,0($5)	C load new s1 limb as early as possible
46
47Loop:	lw	$10,0($4)
48	mflo	$3
49	mfhi	$9
50	addiu	$5,$5,4
51	addu	$3,$3,$2	C add old carry limb to low product limb
52	multu	$8,$7
53	lw	$8,0($5)	C load new s1 limb as early as possible
54	addiu	$6,$6,-1	C decrement loop counter
55	sltu	$2,$3,$2	C carry from previous addition -> $2
56	addu	$3,$10,$3
57	sltu	$10,$3,$10
58	addu	$2,$2,$10
59	sw	$3,0($4)
60	addiu	$4,$4,4
61	bne	$6,$0,Loop
62	 addu	$2,$9,$2	C add high product limb and carry from addition
63
64C wind-down phase 1
65$LC1:	lw	$10,0($4)
66	mflo	$3
67	mfhi	$9
68	addu	$3,$3,$2
69	sltu	$2,$3,$2
70	multu	$8,$7
71	addu	$3,$10,$3
72	sltu	$10,$3,$10
73	addu	$2,$2,$10
74	sw	$3,0($4)
75	addiu	$4,$4,4
76	addu	$2,$9,$2	C add high product limb and carry from addition
77
78C wind-down phase 0
79$LC0:	lw	$10,0($4)
80	mflo	$3
81	mfhi	$9
82	addu	$3,$3,$2
83	sltu	$2,$3,$2
84	addu	$3,$10,$3
85	sltu	$10,$3,$10
86	addu	$2,$2,$10
87	sw	$3,0($4)
88	j	$31
89	addu	$2,$9,$2	C add high product limb and carry from addition
90EPILOGUE(mpn_addmul_1)
91