rshift.asm revision 1.1.1.1
1dnl  IBM POWER mpn_rshift -- Shift a number right.
2
3dnl  Copyright 1992, 1994, 1999, 2000, 2001 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
20
21dnl  INPUT PARAMETERS
22dnl  res_ptr	r3
23dnl  s_ptr	r4
24dnl  size	r5
25dnl  cnt	r6
26
27include(`../config.m4')
28
29ASM_START()
30PROLOGUE(mpn_rshift)
31	sfi	8,6,32
32	mtctr	5		C put limb count in CTR loop register
33	l	0,0(4)		C read least significant limb
34	ai	9,3,-4		C adjust res_ptr since it's offset in the stu:s
35	sle	3,0,8		C compute carry limb, and init MQ register
36	bdz	Lend2		C if just one limb, skip loop
37	lu	0,4(4)		C read 2:nd least significant limb
38	sleq	7,0,8		C compute least significant limb of result
39	bdz	Lend		C if just two limb, skip loop
40Loop:	lu	0,4(4)		C load next higher limb
41	stu	7,4(9)		C store previous result during read latency
42	sleq	7,0,8		C compute result limb
43	bdn	Loop		C loop back until CTR is zero
44Lend:	stu	7,4(9)		C store 2:nd most significant limb
45Lend2:	sre	7,0,6		C compute most significant limb
46	st	7,4(9)		C store it
47	br
48EPILOGUE(mpn_rshift)
49