Austin Schuh | bb1338c | 2024-06-15 19:31:16 -0700 | [diff] [blame] | 1 | dnl MIPS32 mpn_rshift -- Right shift. |
| 2 | |
| 3 | dnl Copyright 1995, 2000, 2002 Free Software Foundation, Inc. |
| 4 | |
| 5 | dnl This file is part of the GNU MP Library. |
| 6 | dnl |
| 7 | dnl The GNU MP Library is free software; you can redistribute it and/or modify |
| 8 | dnl it under the terms of either: |
| 9 | dnl |
| 10 | dnl * the GNU Lesser General Public License as published by the Free |
| 11 | dnl Software Foundation; either version 3 of the License, or (at your |
| 12 | dnl option) any later version. |
| 13 | dnl |
| 14 | dnl or |
| 15 | dnl |
| 16 | dnl * the GNU General Public License as published by the Free Software |
| 17 | dnl Foundation; either version 2 of the License, or (at your option) any |
| 18 | dnl later version. |
| 19 | dnl |
| 20 | dnl or both in parallel, as here. |
| 21 | dnl |
| 22 | dnl The GNU MP Library is distributed in the hope that it will be useful, but |
| 23 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 24 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 25 | dnl for more details. |
| 26 | dnl |
| 27 | dnl You should have received copies of the GNU General Public License and the |
| 28 | dnl GNU Lesser General Public License along with the GNU MP Library. If not, |
| 29 | dnl see https://www.gnu.org/licenses/. |
| 30 | |
| 31 | include(`../config.m4') |
| 32 | |
| 33 | C INPUT PARAMETERS |
| 34 | C res_ptr $4 |
| 35 | C src_ptr $5 |
| 36 | C size $6 |
| 37 | C cnt $7 |
| 38 | |
| 39 | ASM_START() |
| 40 | PROLOGUE(mpn_rshift) |
| 41 | lw $10,0($5) C load first limb |
| 42 | subu $13,$0,$7 |
| 43 | addiu $6,$6,-1 |
| 44 | and $9,$6,4-1 C number of limbs in first loop |
| 45 | beq $9,$0,.L0 C if multiple of 4 limbs, skip first loop |
| 46 | sll $2,$10,$13 C compute function result |
| 47 | |
| 48 | subu $6,$6,$9 |
| 49 | |
| 50 | .Loop0: lw $3,4($5) |
| 51 | addiu $4,$4,4 |
| 52 | addiu $5,$5,4 |
| 53 | addiu $9,$9,-1 |
| 54 | srl $11,$10,$7 |
| 55 | sll $12,$3,$13 |
| 56 | move $10,$3 |
| 57 | or $8,$11,$12 |
| 58 | bne $9,$0,.Loop0 |
| 59 | sw $8,-4($4) |
| 60 | |
| 61 | .L0: beq $6,$0,.Lend |
| 62 | nop |
| 63 | |
| 64 | .Loop: lw $3,4($5) |
| 65 | addiu $4,$4,16 |
| 66 | addiu $6,$6,-4 |
| 67 | srl $11,$10,$7 |
| 68 | sll $12,$3,$13 |
| 69 | |
| 70 | lw $10,8($5) |
| 71 | srl $14,$3,$7 |
| 72 | or $8,$11,$12 |
| 73 | sw $8,-16($4) |
| 74 | sll $9,$10,$13 |
| 75 | |
| 76 | lw $3,12($5) |
| 77 | srl $11,$10,$7 |
| 78 | or $8,$14,$9 |
| 79 | sw $8,-12($4) |
| 80 | sll $12,$3,$13 |
| 81 | |
| 82 | lw $10,16($5) |
| 83 | srl $14,$3,$7 |
| 84 | or $8,$11,$12 |
| 85 | sw $8,-8($4) |
| 86 | sll $9,$10,$13 |
| 87 | |
| 88 | addiu $5,$5,16 |
| 89 | or $8,$14,$9 |
| 90 | bgtz $6,.Loop |
| 91 | sw $8,-4($4) |
| 92 | |
| 93 | .Lend: srl $8,$10,$7 |
| 94 | j $31 |
| 95 | sw $8,0($4) |
| 96 | EPILOGUE(mpn_rshift) |