]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/mips/submul_1.S
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / mips / submul_1.S
CommitLineData
bcb5cee0
UD
1/* MIPS __mpn_submul_1 -- Multiply a limb vector with a single limb and
2subtract the product from a second limb vector.
3
2b778ceb 4Copyright (C) 1995-2021 Free Software Foundation, Inc.
bcb5cee0
UD
5
6This file is part of the GNU MP Library.
7
8The GNU MP Library is free software; you can redistribute it and/or modify
f01ec467
AJ
9it under the terms of the GNU Lesser General Public License as published by
10the Free Software Foundation; either version 2.1 of the License, or (at your
bcb5cee0
UD
11option) any later version.
12
13The GNU MP Library is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
f01ec467 15or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
bcb5cee0
UD
16License for more details.
17
f01ec467 18You should have received a copy of the GNU Lesser General Public License
ab84e3ff 19along with the GNU MP Library. If not, see
5a82c748 20<https://www.gnu.org/licenses/>. */
bcb5cee0
UD
21
22#include <sysdep.h>
23
24/* INPUT PARAMETERS
25 res_ptr $4
26 s1_ptr $5
27 size $6
28 s2_limb $7
29*/
b5e0b658 30#ifdef __PIC__
bcb5cee0
UD
31 .option pic2
32#endif
33ENTRY (__mpn_submul_1)
34 .set noreorder
b5e0b658 35#ifdef __PIC__
bcb5cee0
UD
36 .cpload t9
37#endif
38 .set nomacro
39
40 /* warm up phase 0 */
41 lw $8,0($5)
42
43 /* warm up phase 1 */
44 addiu $5,$5,4
8b2800c0 45#if __mips_isa_rev < 6
bcb5cee0 46 multu $8,$7
8b2800c0
SE
47#else
48 mulu $11,$8,$7
49 muhu $12,$8,$7
50#endif
bcb5cee0
UD
51
52 addiu $6,$6,-1
3e9a9758 53 beq $6,$0,L(LC0)
bcb5cee0
UD
54 move $2,$0 /* zero cy2 */
55
56 addiu $6,$6,-1
3e9a9758 57 beq $6,$0,L(LC1)
bcb5cee0
UD
58 lw $8,0($5) /* load new s1 limb as early as possible */
59
3e9a9758 60L(Loop): lw $10,0($4)
8b2800c0 61#if __mips_isa_rev < 6
bcb5cee0
UD
62 mflo $3
63 mfhi $9
8b2800c0
SE
64#else
65 move $3,$11
66 move $9,$12
67#endif
bcb5cee0
UD
68 addiu $5,$5,4
69 addu $3,$3,$2 /* add old carry limb to low product limb */
8b2800c0 70#if __mips_isa_rev < 6
bcb5cee0 71 multu $8,$7
8b2800c0
SE
72#else
73 mulu $11,$8,$7
74 muhu $12,$8,$7
75#endif
bcb5cee0
UD
76 lw $8,0($5) /* load new s1 limb as early as possible */
77 addiu $6,$6,-1 /* decrement loop counter */
78 sltu $2,$3,$2 /* carry from previous addition -> $2 */
79 subu $3,$10,$3
80 sgtu $10,$3,$10
81 addu $2,$2,$10
82 sw $3,0($4)
83 addiu $4,$4,4
3e9a9758 84 bne $6,$0,L(Loop) /* should be "bnel" */
bcb5cee0
UD
85 addu $2,$9,$2 /* add high product limb and carry from addition */
86
87 /* cool down phase 1 */
3e9a9758 88L(LC1): lw $10,0($4)
8b2800c0 89#if __mips_isa_rev < 6
bcb5cee0
UD
90 mflo $3
91 mfhi $9
8b2800c0
SE
92#else
93 move $3,$11
94 move $9,$12
95#endif
bcb5cee0
UD
96 addu $3,$3,$2
97 sltu $2,$3,$2
8b2800c0 98#if __mips_isa_rev < 6
bcb5cee0 99 multu $8,$7
8b2800c0
SE
100#else
101 mulu $11,$8,$7
102 muhu $12,$8,$7
103#endif
bcb5cee0
UD
104 subu $3,$10,$3
105 sgtu $10,$3,$10
106 addu $2,$2,$10
107 sw $3,0($4)
108 addiu $4,$4,4
109 addu $2,$9,$2 /* add high product limb and carry from addition */
110
111 /* cool down phase 0 */
3e9a9758 112L(LC0): lw $10,0($4)
8b2800c0 113#if __mips_isa_rev < 6
bcb5cee0
UD
114 mflo $3
115 mfhi $9
8b2800c0
SE
116#else
117 move $3,$11
118 move $9,$12
119#endif
bcb5cee0
UD
120 addu $3,$3,$2
121 sltu $2,$3,$2
122 subu $3,$10,$3
123 sgtu $10,$3,$10
124 addu $2,$2,$10
125 sw $3,0($4)
126 j $31
127 addu $2,$9,$2 /* add high product limb and carry from addition */
b5e0b658 128 END (__mpn_submul_1)