xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame^] | 1 | /* MIPS2 __mpn_rshift -- |
| 2 | |
| 3 | Copyright (C) 1995-2016 Free Software Foundation, Inc. |
| 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 |
| 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 |
| 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 |
| 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 15 | License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Lesser General Public License |
| 18 | along with the GNU MP Library. If not, see |
| 19 | <http://www.gnu.org/licenses/>. */ |
| 20 | |
| 21 | #include <sysdep.h> |
| 22 | |
| 23 | /* INPUT PARAMETERS |
| 24 | res_ptr $4 |
| 25 | src_ptr $5 |
| 26 | size $6 |
| 27 | cnt $7 |
| 28 | */ |
| 29 | #ifdef __PIC__ |
| 30 | .option pic2 |
| 31 | #endif |
| 32 | ENTRY (__mpn_rshift) |
| 33 | .set noreorder |
| 34 | #ifdef __PIC__ |
| 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 */ |
| 43 | beq $9,$0,L(L0) /* if multiple of 4 limbs, skip first loop*/ |
| 44 | sll $2,$10,$13 /* compute function result */ |
| 45 | |
| 46 | subu $6,$6,$9 |
| 47 | |
| 48 | L(Loop0): lw $3,4($5) |
| 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 |
| 56 | bne $9,$0,L(Loop0) |
| 57 | sw $8,-4($4) |
| 58 | |
| 59 | L(L0): beq $6,$0,L(Lend) |
| 60 | nop |
| 61 | |
| 62 | L(Loop): lw $3,4($5) |
| 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 |
| 88 | bgtz $6,L(Loop) |
| 89 | sw $8,-4($4) |
| 90 | |
| 91 | L(Lend): srl $8,$10,$7 |
| 92 | j $31 |
| 93 | sw $8,0($4) |
| 94 | END (__mpn_rshift) |