1/* mips3 rshift 2 * 3 * Copyright (C) 1995, 1998, 2000 4 * 2001, 2002 Free Software Foundation, Inc. 5 * 6 * This file is part of Libgcrypt. 7 * 8 * Libgcrypt is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as 10 * published by the Free Software Foundation; either version 2.1 of 11 * the License, or (at your option) any later version. 12 * 13 * Libgcrypt is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 21 */ 22 23/******************* 24 * mpi_limb_t 25 * _gcry_mpih_rshift( mpi_ptr_t wp, ($4) 26 * mpi_ptr_t up, ($5) 27 * mpi_size_t usize, ($6) 28 * unsigned cnt) ($7) 29 */ 30 31 .text 32 .align 2 33 .globl _gcry_mpih_rshift 34 .ent _gcry_mpih_rshift 35_gcry_mpih_rshift: 36 .set noreorder 37 .set nomacro 38 39 ld $10,0($5) # load first limb 40 dsubu $13,$0,$7 41 daddiu $6,$6,-1 42 and $9,$6,4-1 # number of limbs in first loop 43 beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop 44 dsll $2,$10,$13 # compute function result 45 46 dsubu $6,$6,$9 47 48.Loop0: ld $3,8($5) 49 daddiu $4,$4,8 50 daddiu $5,$5,8 51 daddiu $9,$9,-1 52 dsrl $11,$10,$7 53 dsll $12,$3,$13 54 move $10,$3 55 or $8,$11,$12 56 bne $9,$0,.Loop0 57 sd $8,-8($4) 58 59.L0: beq $6,$0,.Lend 60 nop 61 62.Loop: ld $3,8($5) 63 daddiu $4,$4,32 64 daddiu $6,$6,-4 65 dsrl $11,$10,$7 66 dsll $12,$3,$13 67 68 ld $10,16($5) 69 dsrl $14,$3,$7 70 or $8,$11,$12 71 sd $8,-32($4) 72 dsll $9,$10,$13 73 74 ld $3,24($5) 75 dsrl $11,$10,$7 76 or $8,$14,$9 77 sd $8,-24($4) 78 dsll $12,$3,$13 79 80 ld $10,32($5) 81 dsrl $14,$3,$7 82 or $8,$11,$12 83 sd $8,-16($4) 84 dsll $9,$10,$13 85 86 daddiu $5,$5,32 87 or $8,$14,$9 88 bgtz $6,.Loop 89 sd $8,-8($4) 90 91.Lend: dsrl $8,$10,$7 92 j $31 93 sd $8,0($4) 94 .end _gcry_mpih_rshift 95 96