]>
Commit | Line | Data |
---|---|---|
bcb5cee0 UD |
1 | /* MIPS2 __mpn_rshift -- |
2 | ||
dff8da6b | 3 | Copyright (C) 1995-2024 Free Software Foundation, Inc. |
bcb5cee0 UD |
4 | |
5 | This file is part of the GNU MP Library. | |
6 | ||
7 | The GNU MP Library is free software; you can redistribute it and/or modify | |
f01ec467 AJ |
8 | it under the terms of the GNU Lesser General Public License as published by |
9 | the Free Software Foundation; either version 2.1 of the License, or (at your | |
bcb5cee0 UD |
10 | option) any later version. |
11 | ||
12 | The GNU MP Library is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
f01ec467 | 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
bcb5cee0 UD |
15 | License for more details. |
16 | ||
f01ec467 | 17 | You should have received a copy of the GNU Lesser General Public License |
ab84e3ff | 18 | along with the GNU MP Library. If not, see |
5a82c748 | 19 | <https://www.gnu.org/licenses/>. */ |
bcb5cee0 UD |
20 | |
21 | #include <sysdep.h> | |
22 | ||
23 | /* INPUT PARAMETERS | |
24 | res_ptr $4 | |
25 | src_ptr $5 | |
26 | size $6 | |
27 | cnt $7 | |
28 | */ | |
b5e0b658 | 29 | #ifdef __PIC__ |
bcb5cee0 UD |
30 | .option pic2 |
31 | #endif | |
32 | ENTRY (__mpn_rshift) | |
33 | .set noreorder | |
b5e0b658 | 34 | #ifdef __PIC__ |
bcb5cee0 UD |
35 | .cpload t9 |
36 | #endif | |
37 | .set nomacro | |
38 | ||
39 | lw $10,0($5) /* load first limb */ | |
40 | subu $13,$0,$7 | |
41 | addiu $6,$6,-1 | |
42 | and $9,$6,4-1 /* number of limbs in first loop */ | |
3e9a9758 | 43 | beq $9,$0,L(L0) /* if multiple of 4 limbs, skip first loop*/ |
bcb5cee0 UD |
44 | sll $2,$10,$13 /* compute function result */ |
45 | ||
46 | subu $6,$6,$9 | |
47 | ||
3e9a9758 | 48 | L(Loop0): lw $3,4($5) |
bcb5cee0 UD |
49 | addiu $4,$4,4 |
50 | addiu $5,$5,4 | |
51 | addiu $9,$9,-1 | |
52 | srl $11,$10,$7 | |
53 | sll $12,$3,$13 | |
54 | move $10,$3 | |
55 | or $8,$11,$12 | |
3e9a9758 | 56 | bne $9,$0,L(Loop0) |
bcb5cee0 UD |
57 | sw $8,-4($4) |
58 | ||
3e9a9758 | 59 | L(L0): beq $6,$0,L(Lend) |
bcb5cee0 UD |
60 | nop |
61 | ||
3e9a9758 | 62 | L(Loop): lw $3,4($5) |
bcb5cee0 UD |
63 | addiu $4,$4,16 |
64 | addiu $6,$6,-4 | |
65 | srl $11,$10,$7 | |
66 | sll $12,$3,$13 | |
67 | ||
68 | lw $10,8($5) | |
69 | srl $14,$3,$7 | |
70 | or $8,$11,$12 | |
71 | sw $8,-16($4) | |
72 | sll $9,$10,$13 | |
73 | ||
74 | lw $3,12($5) | |
75 | srl $11,$10,$7 | |
76 | or $8,$14,$9 | |
77 | sw $8,-12($4) | |
78 | sll $12,$3,$13 | |
79 | ||
80 | lw $10,16($5) | |
81 | srl $14,$3,$7 | |
82 | or $8,$11,$12 | |
83 | sw $8,-8($4) | |
84 | sll $9,$10,$13 | |
85 | ||
86 | addiu $5,$5,16 | |
87 | or $8,$14,$9 | |
3e9a9758 | 88 | bgtz $6,L(Loop) |
bcb5cee0 UD |
89 | sw $8,-4($4) |
90 | ||
3e9a9758 | 91 | L(Lend): srl $8,$10,$7 |
bcb5cee0 UD |
92 | j $31 |
93 | sw $8,0($4) | |
2cf8794a | 94 | END (__mpn_rshift) |