1
/* mc68020 lshift -- Shift left a low-level natural-number integer.
3
* Copyright (C) 1996, 1998, 2001 Free Software Foundation, Inc.
5
* This file is part of GnuPG.
7
* GnuPG is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* GnuPG is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21
* Note: This code is heavily based on the GNU MP Library.
22
* Actually it's the same code with only minor changes in the
23
* way the data is stored; this is to support the abstraction
24
* of an optional secure memory allocation which may be used
25
* to avoid revealing of sensitive data due to paging etc.
26
* The GNU MP Library itself is published under the LGPL;
27
* however I decided to publish this code under the plain GPL.
32
#include "asm-syntax.h"
37
* mpihelp_lshift( mpi_ptr_t wp, (sp + 4)
38
* mpi_ptr_t up, (sp + 8)
39
* mpi_size_t usize, (sp + 12)
40
* unsigned cnt) (sp + 16)
50
GLOBL C_SYMBOL_NAME(mpihelp_lshift)
52
C_SYMBOL_NAME(mpihelp_lshift:)
53
PROLOG(mpihelp_lshift)
55
/* Save used registers on the stack. */
56
moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp)
58
/* Copy the arguments to registers. */
59
movel MEM_DISP(sp,28),R(res_ptr)
60
movel MEM_DISP(sp,32),R(s_ptr)
61
movel MEM_DISP(sp,36),R(s_size)
62
movel MEM_DISP(sp,40),R(cnt)
67
cmpl R(s_ptr),R(res_ptr)
68
bls L(Lspecial) /* jump if s_ptr >= res_ptr */
69
#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
70
lea MEM_INDX1(s_ptr,s_size,l,4),R(a2)
71
#else /* not mc68020 */
74
lea MEM_INDX(s_ptr,d0,l),R(a2)
77
bls L(Lspecial) /* jump if res_ptr >= s_ptr + s_size */
83
#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
84
lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr)
85
lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr)
86
#else /* not mc68000 */
89
addl R(s_size),R(s_ptr)
90
addl R(s_size),R(res_ptr)
92
movel MEM_PREDEC(s_ptr),R(d2)
94
lsrl R(d5),R(d0) /* compute carry limb */
105
movel MEM_PREDEC(s_ptr),R(d2)
109
movel R(d1),MEM_PREDEC(res_ptr)
112
movel MEM_PREDEC(s_ptr),R(d1)
116
movel R(d2),MEM_PREDEC(res_ptr)
119
dbf R(s_size),L(Loop)
120
subl #0x10000,R(s_size)
124
movel R(d1),MEM_PREDEC(res_ptr) /* store least significant limb */
126
/* Restore used registers from stack frame. */
127
moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
130
/* We loop from least significant end of the arrays, which is only
131
permissable if the source and destination don't overlap, since the
132
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)
161
EPILOG(mpihelp_lshift)