]> git.ipfire.org Git - thirdparty/glibc.git/blob - ports/sysdeps/mips/mips64/mul_1.S
e1360658ae89ca88aaaaba9bf119826f48e131a1
[thirdparty/glibc.git] / ports / sysdeps / mips / mips64 / mul_1.S
1 /* MIPS3 __mpn_mul_1 -- Multiply a limb vector with a single limb and
2 * store the product in a second limb vector.
3 *
4 * Copyright (C) 1992-2013 Free Software Foundation, Inc.
5 *
6 * This file is part of the GNU MP Library.
7 *
8 * The GNU MP Library is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or (at your
11 * option) any later version.
12 *
13 * The GNU MP Library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 * License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with the GNU MP Library. If not, see
20 * <http://www.gnu.org/licenses/>.
21 */
22
23 #include <sysdep.h>
24 #include <sys/asm.h>
25
26 /* INPUT PARAMETERS
27 * res_ptr $4
28 * s1_ptr $5
29 * size $6
30 * s2_limb $7
31 */
32
33 #ifdef __PIC__
34 .option pic2
35 #endif
36 ENTRY (__mpn_mul_1)
37 #ifdef __PIC__
38 SETUP_GP /* ??? unused */
39 #endif
40 .set noreorder
41 .set nomacro
42
43 # warm up phase 0
44 ld $8,0($5)
45
46 # warm up phase 1
47 daddiu $5,$5,8
48 dmultu $8,$7
49
50 daddiu $6,$6,-1
51 beq $6,$0,L(LC0)
52 move $2,$0 # zero cy2
53
54 daddiu $6,$6,-1
55 beq $6,$0,L(LC1)
56 ld $8,0($5) # load new s1 limb as early as possible
57
58 L(Loop): mflo $10
59 mfhi $9
60 daddiu $5,$5,8
61 daddu $10,$10,$2 # add old carry limb to low product limb
62 dmultu $8,$7
63 ld $8,0($5) # load new s1 limb as early as possible
64 daddiu $6,$6,-1 # decrement loop counter
65 sltu $2,$10,$2 # carry from previous addition -> $2
66 sd $10,0($4)
67 daddiu $4,$4,8
68 bne $6,$0,L(Loop)
69 daddu $2,$9,$2 # add high product limb and carry from addition
70
71 # cool down phase 1
72 L(LC1): mflo $10
73 mfhi $9
74 daddu $10,$10,$2
75 sltu $2,$10,$2
76 dmultu $8,$7
77 sd $10,0($4)
78 daddiu $4,$4,8
79 daddu $2,$9,$2 # add high product limb and carry from addition
80
81 # cool down phase 0
82 L(LC0): mflo $10
83 mfhi $9
84 daddu $10,$10,$2
85 sltu $2,$10,$2
86 sd $10,0($4)
87 j $31
88 daddu $2,$9,$2 # add high product limb and carry from addition
89
90 END (__mpn_mul_1)