1 /* mc68020 __gmpn_lshift -- Shift left a low-level natural-number integer.
3 Copyright (C) 1996, 1999, 2000 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; 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. */
30 #include "asm-syntax.h"
39 GLOBL C_SYMBOL_NAME(__gmpn_lshift)
41 C_SYMBOL_NAME(__gmpn_lshift:)
44 /* Save used registers on the stack. */
45 moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp)
47 /* Copy the arguments to registers. */
48 movel MEM_DISP(sp,28),R(res_ptr)
49 movel MEM_DISP(sp,32),R(s_ptr)
50 movel MEM_DISP(sp,36),R(s_size)
51 movel MEM_DISP(sp,40),R(cnt)
56 cmpl R(s_ptr),R(res_ptr)
57 bls L(Lspecial) /* jump if s_ptr >= res_ptr */
58 #if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
59 lea MEM_INDX1(s_ptr,s_size,l,4),R(a2)
60 #else /* not mc68020 */
63 lea MEM_INDX(s_ptr,d0,l),R(a2)
66 bls L(Lspecial) /* jump if res_ptr >= s_ptr + s_size */
72 #if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
73 lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr)
74 lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr)
75 #else /* not mc68000 */
78 addl R(s_size),R(s_ptr)
79 addl R(s_size),R(res_ptr)
81 movel MEM_PREDEC(s_ptr),R(d2)
83 lsrl R(d5),R(d0) /* compute carry limb */
94 movel MEM_PREDEC(s_ptr),R(d2)
98 movel R(d1),MEM_PREDEC(res_ptr)
101 movel MEM_PREDEC(s_ptr),R(d1)
105 movel R(d2),MEM_PREDEC(res_ptr)
108 dbf R(s_size),L(Loop)
109 subl #0x10000,R(s_size)
113 movel R(d1),MEM_PREDEC(res_ptr) /* store least significant limb */
115 /* Restore used registers from stack frame. */
116 moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
119 /* We loop from least significant end of the arrays, which is only
120 permissable if the source and destination don't overlap, since the
121 function is documented to work for overlapping source and destination. */
124 clrl R(d0) /* initialize carry */
131 movel MEM_POSTINC(s_ptr),R(d2)
133 movel R(d2),MEM_POSTINC(res_ptr)
135 movel MEM_POSTINC(s_ptr),R(d2)
137 movel R(d2),MEM_POSTINC(res_ptr)
139 dbf R(s_size),L(LLoop)
140 addxl R(d0),R(d0) /* save cy in lsb */
141 subl #0x10000,R(s_size)
143 lsrl #1,R(d0) /* restore cy */
147 /* Restore used registers from stack frame. */
148 moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
150 EPILOG(__gmpn_lshift)