1; 29000 __gmpn_lshift --
2
3; Copyright 1992, 1994, 2000 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 3 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 http://www.gnu.org/licenses/.
19
20
21; INPUT PARAMETERS
22; res_ptr	lr2
23; s1_ptr	lr3
24; s2_ptr	lr4
25; size		lr5
26
27; We use the loadm/storem instructions and operate on chunks of 8
28; limbs/per iteration, until less than 8 limbs remain.
29
30	.sect .lit,lit
31	.text
32	.align	4
33	.global	___gmpn_lshift
34	.word	0x60000
35___gmpn_lshift:
36	sll	gr116,lr4,2
37	add	lr3,gr116,lr3
38	add	lr2,gr116,lr2
39	sub	lr3,lr3,4
40	load	0,0,gr119,lr3
41
42	subr	gr116,lr5,32
43	srl	gr96,gr119,gr116	; return value
44	sub	lr4,lr4,1		; actual loop count is SIZE - 1
45
46	srl	gr117,lr4,3		; chuck count = (actual count) / 8
47	cpeq	gr118,gr117,0
48	jmpt	gr118,Ltail
49	 mtsr	fc,lr5
50
51	sub	gr117,gr117,2		; count for jmpfdec
52
53; Main loop working 8 limbs/iteration.
54Loop:	sub	lr3,lr3,32
55	mtsrim	cr,(8-1)
56	loadm	0,0,gr100,lr3
57
58	extract	gr109,gr119,gr107
59	extract	gr108,gr107,gr106
60	extract	gr107,gr106,gr105
61	extract	gr106,gr105,gr104
62	extract	gr105,gr104,gr103
63	extract	gr104,gr103,gr102
64	extract	gr103,gr102,gr101
65	extract	gr102,gr101,gr100
66
67	sub	lr2,lr2,32
68	mtsrim	cr,(8-1)
69	storem	0,0,gr102,lr2
70	jmpfdec	gr117,Loop
71	 or	gr119,gr100,0
72
73; Code for the last up-to-7 limbs.
74
75	and	lr4,lr4,(8-1)
76Ltail:	cpeq	gr118,lr4,0
77	jmpt	gr118,Lend
78	 sub	lr4,lr4,2		; count for jmpfdec
79
80Loop2:	sub	lr3,lr3,4
81	load	0,0,gr116,lr3
82	extract	gr117,gr119,gr116
83	sub	lr2,lr2,4
84	store	0,0,gr117,lr2
85	jmpfdec	lr4,Loop2
86	 or	gr119,gr116,0
87
88Lend:	extract	gr117,gr119,0
89	sub	lr2,lr2,4
90	jmpi	lr0
91	 store	0,0,gr117,lr2
92