]>
Commit | Line | Data |
---|---|---|
d0c2d3b3 UD |
1 | /* MIPS3 __mpn_add_n -- Add two limb vectors of the same length > 0 and |
2 | * store sum in a third limb vector. | |
3 | * | |
6d7e8eda | 4 | * Copyright (C) 1995-2023 Free Software Foundation, Inc. |
d0c2d3b3 UD |
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 | |
f01ec467 AJ |
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 | |
d0c2d3b3 UD |
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 | |
f01ec467 | 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
d0c2d3b3 UD |
16 | * License for more details. |
17 | * | |
f01ec467 | 18 | * You should have received a copy of the GNU Lesser General Public License |
ab84e3ff | 19 | * along with the GNU MP Library. If not, see |
5a82c748 | 20 | * <https://www.gnu.org/licenses/>. |
d0c2d3b3 UD |
21 | */ |
22 | ||
23 | #include <sysdep.h> | |
3e9a9758 | 24 | #include <sys/asm.h> |
d0c2d3b3 UD |
25 | |
26 | /* | |
27 | * INPUT PARAMETERS | |
28 | * res_ptr $4 | |
29 | * s1_ptr $5 | |
30 | * s2_ptr $6 | |
31 | * size $7 | |
32 | */ | |
5494bc3a | 33 | #ifdef __PIC__ |
d0c2d3b3 UD |
34 | .option pic2 |
35 | #endif | |
a6ee1783 | 36 | ENTRY (__mpn_add_n) |
5494bc3a | 37 | #ifdef __PIC__ |
3e9a9758 | 38 | SETUP_GP /* ??? unused */ |
d0c2d3b3 | 39 | #endif |
3e9a9758 | 40 | .set noreorder |
d0c2d3b3 UD |
41 | .set nomacro |
42 | ||
43 | ld $10,0($5) | |
44 | ld $11,0($6) | |
45 | ||
46 | daddiu $7,$7,-1 | |
47 | and $9,$7,4-1 # number of limbs in first loop | |
3e9a9758 RM |
48 | beq $9,$0,L(L0) # if multiple of 4 limbs, skip first loop |
49 | move $2,$0 | |
d0c2d3b3 UD |
50 | |
51 | dsubu $7,$7,$9 | |
52 | ||
3e9a9758 | 53 | L(Loop0): daddiu $9,$9,-1 |
d0c2d3b3 UD |
54 | ld $12,8($5) |
55 | daddu $11,$11,$2 | |
56 | ld $13,8($6) | |
57 | sltu $8,$11,$2 | |
58 | daddu $11,$10,$11 | |
59 | sltu $2,$11,$10 | |
60 | sd $11,0($4) | |
61 | or $2,$2,$8 | |
62 | ||
63 | daddiu $5,$5,8 | |
64 | daddiu $6,$6,8 | |
65 | move $10,$12 | |
66 | move $11,$13 | |
3e9a9758 RM |
67 | bne $9,$0,L(Loop0) |
68 | daddiu $4,$4,8 | |
d0c2d3b3 | 69 | |
3e9a9758 RM |
70 | L(L0): beq $7,$0,L(Lend) |
71 | nop | |
d0c2d3b3 | 72 | |
3e9a9758 | 73 | L(Loop): daddiu $7,$7,-4 |
d0c2d3b3 UD |
74 | |
75 | ld $12,8($5) | |
76 | daddu $11,$11,$2 | |
77 | ld $13,8($6) | |
78 | sltu $8,$11,$2 | |
79 | daddu $11,$10,$11 | |
80 | sltu $2,$11,$10 | |
81 | sd $11,0($4) | |
82 | or $2,$2,$8 | |
83 | ||
84 | ld $10,16($5) | |
85 | daddu $13,$13,$2 | |
86 | ld $11,16($6) | |
87 | sltu $8,$13,$2 | |
88 | daddu $13,$12,$13 | |
89 | sltu $2,$13,$12 | |
90 | sd $13,8($4) | |
91 | or $2,$2,$8 | |
92 | ||
93 | ld $12,24($5) | |
94 | daddu $11,$11,$2 | |
95 | ld $13,24($6) | |
96 | sltu $8,$11,$2 | |
97 | daddu $11,$10,$11 | |
98 | sltu $2,$11,$10 | |
99 | sd $11,16($4) | |
100 | or $2,$2,$8 | |
101 | ||
102 | ld $10,32($5) | |
103 | daddu $13,$13,$2 | |
104 | ld $11,32($6) | |
105 | sltu $8,$13,$2 | |
106 | daddu $13,$12,$13 | |
107 | sltu $2,$13,$12 | |
108 | sd $13,24($4) | |
109 | or $2,$2,$8 | |
110 | ||
111 | daddiu $5,$5,32 | |
112 | daddiu $6,$6,32 | |
113 | ||
3e9a9758 RM |
114 | bne $7,$0,L(Loop) |
115 | daddiu $4,$4,32 | |
d0c2d3b3 | 116 | |
3e9a9758 | 117 | L(Lend): daddu $11,$11,$2 |
d0c2d3b3 UD |
118 | sltu $8,$11,$2 |
119 | daddu $11,$10,$11 | |
120 | sltu $2,$11,$10 | |
121 | sd $11,0($4) | |
122 | j $31 | |
123 | or $2,$2,$8 | |
124 | ||
a6ee1783 | 125 | END (__mpn_add_n) |