1 dnl mc68020 mpn_rshift
-- mpn right shift.
3 dnl Copyright
1996, 1999-2003 Free Software Foundation
, Inc.
5 dnl
This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
8 dnl it under the terms of
either:
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.
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
20 dnl
or both
in parallel
, as here.
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
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
/.
31 include(`..
/config.m4
')
39 C mp_limb_t mpn_rshift (mp_ptr res_ptr, mp_srcptr s_ptr, mp_size_t s_size,
42 C The "cnt" parameter is either 16 bits or 32 bits depending on
43 C SIZEOF_UNSIGNED (see ABI notes in mpn/m68k/README). The value is of
44 C course only 1 to 31. When loaded as 16 bits there's garbage
in the upper
45 C half
, hence the use of cmpw. The shift instructions take the their count
46 C modulo
64, so the upper part doesn
't matter to them either.
60 ifdef(`SIZEOF_UNSIGNED',,
61 `m4_error
(`SIZEOF_UNSIGNED
not defined
, should be
in config.m4
65 C Save used registers on the stack.
66 moveml d2
-d6
/a2
, M
(-,sp)
68 C Copy the arguments to registers.
69 movel M
(sp,28), res_ptr
71 movel M
(sp,36), s_size
72 ifelse
(SIZEOF_UNSIGNED
,2,
73 ` movew M
(sp,40), cnt
',
74 ` movel M(sp,40), cnt')
80 bls L
(Lspecial
) C jump if res_ptr
>= s_ptr
82 ifelse
(scale_available_p
,1,`
83 lea M
(res_ptr
,s_size
,l
,4), a2
87 lea M(res_ptr,d0,l), a2
90 bls L
(Lspecial
) C jump if s_ptr
>= res_ptr
+ s_size
97 lsll d5
, d0 C compute carry limb
112 movel d1
, M
(res_ptr
,+)
119 movel d2
, M
(res_ptr
,+)
123 subl #
0x10000, s_size
127 movel d1
, M
(res_ptr
) C store most significant limb
129 C Restore used registers from stack frame.
130 moveml M
(sp,+), d2
-d6
/a2
133 C We
loop from most significant
end of the arrays
, which is only permissable
134 C if the source
and destination don
't overlap, since the function is
135 C documented to work for overlapping source and destination.
138 ifelse(scale_available_p,1,`
139 lea M(s_ptr,s_size,l,4), s_ptr
140 lea M(res_ptr,s_size,l,4), res_ptr
148 clrl d0 C initialize carry
157 movel d2, M(-,res_ptr)
161 movel d2, M(-,res_ptr)
164 roxrl #1, d0 C save cy in msb
165 subl #0x10000, s_size
167 addl d0, d0 C restore cy
171 C Restore used registers from stack frame.
172 moveml M(sp,+), d2-d6/a2