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