rshift.asm revision 1.1 1 1.1 mrg dnl SPARC mpn_rshift -- Shift a number right.
2 1.1 mrg
3 1.1 mrg dnl Copyright 1995, 1996, 2000 Free Software Foundation, Inc.
4 1.1 mrg
5 1.1 mrg dnl This file is part of the GNU MP Library.
6 1.1 mrg
7 1.1 mrg dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 1.1 mrg dnl it under the terms of the GNU Lesser General Public License as published
9 1.1 mrg dnl by the Free Software Foundation; either version 3 of the License, or (at
10 1.1 mrg dnl your option) any later version.
11 1.1 mrg
12 1.1 mrg dnl The GNU MP Library is distributed in the hope that it will be useful, but
13 1.1 mrg dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 1.1 mrg dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 1.1 mrg dnl License for more details.
16 1.1 mrg
17 1.1 mrg dnl You should have received a copy of the GNU Lesser General Public License
18 1.1 mrg dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
19 1.1 mrg
20 1.1 mrg
21 1.1 mrg include(`../config.m4')
22 1.1 mrg
23 1.1 mrg C INPUT PARAMETERS
24 1.1 mrg C res_ptr %o0
25 1.1 mrg C src_ptr %o1
26 1.1 mrg C size %o2
27 1.1 mrg C cnt %o3
28 1.1 mrg
29 1.1 mrg ASM_START()
30 1.1 mrg PROLOGUE(mpn_rshift)
31 1.1 mrg ld [%o1],%g2 C load first limb
32 1.1 mrg sub %g0,%o3,%o5 C negate shift count
33 1.1 mrg add %o2,-1,%o2
34 1.1 mrg andcc %o2,4-1,%g4 C number of limbs in first loop
35 1.1 mrg sll %g2,%o5,%g1 C compute function result
36 1.1 mrg be L(0) C if multiple of 4 limbs, skip first loop
37 1.1 mrg st %g1,[%sp+80]
38 1.1 mrg
39 1.1 mrg sub %o2,%g4,%o2 C adjust count for main loop
40 1.1 mrg
41 1.1 mrg L(loop0):
42 1.1 mrg ld [%o1+4],%g3
43 1.1 mrg add %o0,4,%o0
44 1.1 mrg add %o1,4,%o1
45 1.1 mrg addcc %g4,-1,%g4
46 1.1 mrg srl %g2,%o3,%o4
47 1.1 mrg sll %g3,%o5,%g1
48 1.1 mrg mov %g3,%g2
49 1.1 mrg or %o4,%g1,%o4
50 1.1 mrg bne L(loop0)
51 1.1 mrg st %o4,[%o0-4]
52 1.1 mrg
53 1.1 mrg L(0): tst %o2
54 1.1 mrg be L(end)
55 1.1 mrg nop
56 1.1 mrg
57 1.1 mrg L(loop):
58 1.1 mrg ld [%o1+4],%g3
59 1.1 mrg add %o0,16,%o0
60 1.1 mrg addcc %o2,-4,%o2
61 1.1 mrg srl %g2,%o3,%o4
62 1.1 mrg sll %g3,%o5,%g1
63 1.1 mrg
64 1.1 mrg ld [%o1+8],%g2
65 1.1 mrg srl %g3,%o3,%g4
66 1.1 mrg or %o4,%g1,%o4
67 1.1 mrg st %o4,[%o0-16]
68 1.1 mrg sll %g2,%o5,%g1
69 1.1 mrg
70 1.1 mrg ld [%o1+12],%g3
71 1.1 mrg srl %g2,%o3,%o4
72 1.1 mrg or %g4,%g1,%g4
73 1.1 mrg st %g4,[%o0-12]
74 1.1 mrg sll %g3,%o5,%g1
75 1.1 mrg
76 1.1 mrg ld [%o1+16],%g2
77 1.1 mrg srl %g3,%o3,%g4
78 1.1 mrg or %o4,%g1,%o4
79 1.1 mrg st %o4,[%o0-8]
80 1.1 mrg sll %g2,%o5,%g1
81 1.1 mrg
82 1.1 mrg add %o1,16,%o1
83 1.1 mrg or %g4,%g1,%g4
84 1.1 mrg bne L(loop)
85 1.1 mrg st %g4,[%o0-4]
86 1.1 mrg
87 1.1 mrg L(end): srl %g2,%o3,%g2
88 1.1 mrg st %g2,[%o0-0]
89 1.1 mrg retl
90 1.1 mrg ld [%sp+80],%o0
91 1.1 mrg EPILOGUE(mpn_rshift)
92