1 /* mc68020 __mpn_rshift -- Shift right a low-level natural-number integer.
3 Copyright (C) 1996-2024 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library.
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 2.1 of the License, or (at your
10 option) any later version.
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.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the GNU MP Library. If not, see <https://www.gnu.org/licenses/>. */
29 #include "asm-syntax.h"
38 /* Save used registers on the stack. */
39 moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp)
40 cfi_adjust_cfa_offset (6*4)
41 cfi_rel_offset (R(d2), 0)
42 cfi_rel_offset (R(d3), 4)
43 cfi_rel_offset (R(d4), 8)
44 cfi_rel_offset (R(d5), 12)
45 cfi_rel_offset (R(d6), 16)
46 cfi_rel_offset (R(a2), 20)
48 /* Copy the arguments to registers. */
49 movel MEM_DISP(sp,28),R(res_ptr)
50 movel MEM_DISP(sp,32),R(s_ptr)
51 movel MEM_DISP(sp,36),R(s_size)
52 movel MEM_DISP(sp,40),R(cnt)
57 cmpl R(res_ptr),R(s_ptr)
58 bls L(Lspecial) /* jump if res_ptr >= s_ptr */
59 #if M68K_SCALE_AVAILABLE
60 lea MEM_INDX1(res_ptr,s_size,l,4),R(a2)
64 lea MEM_INDX(res_ptr,d0,l),R(a2)
67 bls L(Lspecial) /* jump if s_ptr >= res_ptr + s_size */
72 movel MEM_POSTINC(s_ptr),R(d2)
74 lsll R(d5),R(d0) /* compute carry limb */
85 movel MEM_POSTINC(s_ptr),R(d2)
89 movel R(d1),MEM_POSTINC(res_ptr)
92 movel MEM_POSTINC(s_ptr),R(d1)
96 movel R(d2),MEM_POSTINC(res_ptr)
100 subl #0x10000,R(s_size)
104 movel R(d1),MEM(res_ptr) /* store most significant limb */
106 /* Restore used registers from stack frame. */
107 moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
109 cfi_adjust_cfa_offset (-6*4)
118 /* We loop from most significant end of the arrays, which is only
119 permissible if the source and destination don't overlap, since the
120 function is documented to work for overlapping source and destination. */
124 #if M68K_SCALE_AVAILABLE
125 lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr)
126 lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr)
128 movel R(s_size),R(d0)
131 addl R(d0),R(res_ptr)
134 clrl R(d0) /* initialize carry */
141 movel MEM_PREDEC(s_ptr),R(d2)
143 movel R(d2),MEM_PREDEC(res_ptr)
145 movel MEM_PREDEC(s_ptr),R(d2)
147 movel R(d2),MEM_PREDEC(res_ptr)
149 dbf R(s_size),L(LLoop)
150 roxrl #1,R(d0) /* save cy in msb */
151 subl #0x10000,R(s_size)
153 addl R(d0),R(d0) /* restore cy */
157 /* Restore used registers from stack frame. */
158 moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
159 cfi_adjust_cfa_offset (-6*4)