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