Tizen 2.1 base
[external/gmp.git] / mpn / a29k / rshift.s
1 ; 29000 __gmpn_rshift --
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_rshift
34         .word   0x60000
35 ___gmpn_rshift:
36         load    0,0,gr119,lr3
37         add     lr3,lr3,4
38
39         subr    gr116,lr5,32
40         sll     gr96,gr119,gr116        ; return value
41         sub     lr4,lr4,1               ; actual loop count is SIZE - 1
42
43         srl     gr117,lr4,3             ; chuck count = (actual count) / 8
44         cpeq    gr118,gr117,0
45         jmpt    gr118,Ltail
46          mtsr   fc,gr116
47
48         sub     gr117,gr117,2           ; count for jmpfdec
49
50 ; Main loop working 8 limbs/iteration.
51 Loop:   mtsrim  cr,(8-1)
52         loadm   0,0,gr100,lr3
53         add     lr3,lr3,32
54
55         extract gr98,gr100,gr119
56         extract gr99,gr101,gr100
57         extract gr100,gr102,gr101
58         extract gr101,gr103,gr102
59         extract gr102,gr104,gr103
60         extract gr103,gr105,gr104
61         extract gr104,gr106,gr105
62         extract gr105,gr107,gr106
63
64         mtsrim  cr,(8-1)
65         storem  0,0,gr98,lr2
66         add     lr2,lr2,32
67         jmpfdec gr117,Loop
68          or     gr119,gr107,0
69
70 ; Code for the last up-to-7 limbs.
71
72         and     lr4,lr4,(8-1)
73 Ltail:  cpeq    gr118,lr4,0
74         jmpt    gr118,Lend
75          sub    lr4,lr4,2               ; count for jmpfdec
76
77 Loop2:  load    0,0,gr100,lr3
78         add     lr3,lr3,4
79         extract gr117,gr100,gr119
80         store   0,0,gr117,lr2
81         add     lr2,lr2,4
82         jmpfdec lr4,Loop2
83          or     gr119,gr100,0
84
85 Lend:   srl     gr117,gr119,lr5
86         jmpi    lr0
87          store  0,0,gr117,lr2