blob: 4b54510408f5e87c2d4e1a3fec62f748aa6d14b0 [file] [log] [blame]
Austin Schuhbb1338c2024-06-15 19:31:16 -07001dnl MIPS32 mpn_rshift -- Right shift.
2
3dnl Copyright 1995, 2000, 2002 Free Software Foundation, Inc.
4
5dnl This file is part of the GNU MP Library.
6dnl
7dnl The GNU MP Library is free software; you can redistribute it and/or modify
8dnl it under the terms of either:
9dnl
10dnl * the GNU Lesser General Public License as published by the Free
11dnl Software Foundation; either version 3 of the License, or (at your
12dnl option) any later version.
13dnl
14dnl or
15dnl
16dnl * the GNU General Public License as published by the Free Software
17dnl Foundation; either version 2 of the License, or (at your option) any
18dnl later version.
19dnl
20dnl or both in parallel, as here.
21dnl
22dnl The GNU MP Library is distributed in the hope that it will be useful, but
23dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25dnl for more details.
26dnl
27dnl You should have received copies of the GNU General Public License and the
28dnl GNU Lesser General Public License along with the GNU MP Library. If not,
29dnl see https://www.gnu.org/licenses/.
30
31include(`../config.m4')
32
33C INPUT PARAMETERS
34C res_ptr $4
35C src_ptr $5
36C size $6
37C cnt $7
38
39ASM_START()
40PROLOGUE(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)
96EPILOGUE(mpn_rshift)