1/* MIPS3 __mpn_rshift -- 2 * 3 * Copyright (C) 1995-2021 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 * <https://www.gnu.org/licenses/>. 20 */ 21 22#include <sysdep.h> 23#include <sys/asm.h> 24 25/* INPUT PARAMETERS 26 * res_ptr $4 27 * src_ptr $5 28 * size $6 29 * cnt $7 30 */ 31 32#ifdef __PIC__ 33 .option pic2 34#endif 35ENTRY (__mpn_rshift) 36#ifdef __PIC__ 37 SETUP_GP /* ??? unused */ 38#endif 39 .set noreorder 40 .set nomacro 41 42 ld $10,0($5) # load first limb 43 dsubu $13,$0,$7 44 daddiu $6,$6,-1 45 and $9,$6,4-1 # number of limbs in first loop 46 beq $9,$0,L(L0) # if multiple of 4 limbs, skip first loop 47 dsll $2,$10,$13 # compute function result 48 49 dsubu $6,$6,$9 50 51L(Loop0): ld $3,8($5) 52 daddiu $4,$4,8 53 daddiu $5,$5,8 54 daddiu $9,$9,-1 55 dsrl $11,$10,$7 56 dsll $12,$3,$13 57 move $10,$3 58 or $8,$11,$12 59 bne $9,$0,L(Loop0) 60 sd $8,-8($4) 61 62L(L0): beq $6,$0,L(Lend) 63 nop 64 65L(Loop): ld $3,8($5) 66 daddiu $4,$4,32 67 daddiu $6,$6,-4 68 dsrl $11,$10,$7 69 dsll $12,$3,$13 70 71 ld $10,16($5) 72 dsrl $14,$3,$7 73 or $8,$11,$12 74 sd $8,-32($4) 75 dsll $9,$10,$13 76 77 ld $3,24($5) 78 dsrl $11,$10,$7 79 or $8,$14,$9 80 sd $8,-24($4) 81 dsll $12,$3,$13 82 83 ld $10,32($5) 84 dsrl $14,$3,$7 85 or $8,$11,$12 86 sd $8,-16($4) 87 dsll $9,$10,$13 88 89 daddiu $5,$5,32 90 or $8,$14,$9 91 bgtz $6,L(Loop) 92 sd $8,-8($4) 93 94L(Lend): dsrl $8,$10,$7 95 j $31 96 sd $8,0($4) 97END (__mpn_rshift) 98