1 /* mc68020 __mpn_lshift -- Shift left a low-level natural-number integer.
3 Copyright (C) 1996-2015 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 <http://www.gnu.org/licenses/>. */
29 #include "asm-syntax.h"
39 /* Save used registers on the stack. */
40 moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp)
41 cfi_adjust_cfa_offset (6*4)
42 cfi_rel_offset (R(d2), 0)
43 cfi_rel_offset (R(d3), 4)
44 cfi_rel_offset (R(d4), 8)
45 cfi_rel_offset (R(d5), 12)
46 cfi_rel_offset (R(d6), 16)
47 cfi_rel_offset (R(a2), 20)
49 /* Copy the arguments to registers. */
50 movel MEM_DISP(sp,28),R(res_ptr)
51 movel MEM_DISP(sp,32),R(s_ptr)
52 movel MEM_DISP(sp,36),R(s_size)
53 movel MEM_DISP(sp,40),R(cnt)
58 cmpl R(s_ptr),R(res_ptr)
59 bls L(Lspecial) /* jump if s_ptr >= res_ptr */
60 #if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
61 lea MEM_INDX1(s_ptr,s_size,l,4),R(a2)
62 #else /* not mc68020 */
65 lea MEM_INDX(s_ptr,d0,l),R(a2)
68 bls L(Lspecial) /* jump if res_ptr >= s_ptr + s_size */
74 #if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
75 lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr)
76 lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr)
77 #else /* not mc68000 */
80 addl R(s_size),R(s_ptr)
81 addl R(s_size),R(res_ptr)
83 movel MEM_PREDEC(s_ptr),R(d2)
85 lsrl R(d5),R(d0) /* compute carry limb */
96 movel MEM_PREDEC(s_ptr),R(d2)
100 movel R(d1),MEM_PREDEC(res_ptr)
103 movel MEM_PREDEC(s_ptr),R(d1)
107 movel R(d2),MEM_PREDEC(res_ptr)
110 dbf R(s_size),L(Loop)
111 subl #0x10000,R(s_size)
115 movel R(d1),MEM_PREDEC(res_ptr) /* store least significant limb */
117 /* Restore used registers from stack frame. */
118 moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
120 cfi_adjust_cfa_offset (-6*4)
129 /* We loop from least significant end of the arrays, which is only
130 permissible if the source and destination don't overlap, since the
131 function is documented to work for overlapping source and destination. */
135 clrl R(d0) /* initialize carry */
142 movel MEM_POSTINC(s_ptr),R(d2)
144 movel R(d2),MEM_POSTINC(res_ptr)
146 movel MEM_POSTINC(s_ptr),R(d2)
148 movel R(d2),MEM_POSTINC(res_ptr)
150 dbf R(s_size),L(LLoop)
151 addxl R(d0),R(d0) /* save cy in lsb */
152 subl #0x10000,R(s_size)
154 lsrl #1,R(d0) /* restore cy */
158 /* Restore used registers from stack frame. */
159 moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
160 cfi_adjust_cfa_offset (-6*4)