[project @ 2000-08-21 14:16:57 by simonmar]
[ghc-hetmet.git] / ghc / rts / gmp / mpn / powerpc32 / rshift.s
1 # PowerPC-32 __mpn_rshift --
2
3 # Copyright (C) 1995 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 Library General Public License as published by
9 # the Free Software Foundation; either version 2 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 Library General Public
15 # License for more details.
16
17 # You should have received a copy of the GNU Library General Public License
18 # along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
19 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 # MA 02111-1307, USA.
21
22
23 # INPUT PARAMETERS
24 # res_ptr       r3
25 # s1_ptr        r4
26 # size          r5
27 # cnt           r6
28
29         .toc
30 .csect  .text[PR]
31         .align  2
32         .globl  __mpn_rshift
33         .globl  .__mpn_rshift
34         .csect  __mpn_rshift[DS]
35 __mpn_rshift:
36         .long   .__mpn_rshift,  TOC[tc0],       0
37         .csect  .text[PR]
38 .__mpn_rshift:
39         mtctr   5               # copy size into CTR
40         addi    7,3,-4          # move adjusted res_ptr to free return reg
41         subfic  8,6,32
42         lwz     11,0(4)         # load first s1 limb
43         slw     3,11,8          # compute function return value
44         bdz     Lend1
45
46 Loop:   lwzu    10,4(4)
47         srw     9,11,6
48         slw     12,10,8
49         or      9,9,12
50         stwu    9,4(7)
51         bdz     Lend2
52         lwzu    11,4(4)
53         srw     9,10,6
54         slw     12,11,8
55         or      9,9,12
56         stwu    9,4(7)
57         bdnz    Loop
58
59 Lend1:  srw     0,11,6
60         stw     0,4(7)
61         blr
62
63 Lend2:  srw     0,10,6
64         stw     0,4(7)
65         blr