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