3
* Copyright (C) 1992, 1994, 1998,
4
* 2001 Free Software Foundation, Inc.
6
* This file is part of GnuPG.
8
* GnuPG is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* GnuPG is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22
* Note: This code is heavily based on the GNU MP Library.
23
* Actually it's the same code with only minor changes in the
24
* way the data is stored; this is to support the abstraction
25
* of an optional secure memory allocation which may be used
26
* to avoid revealing of sensitive data due to paging etc.
27
* The GNU MP Library itself is published under the LGPL;
28
* however I decided to publish this code under the plain GPL.
33
#include "asm-syntax.h"
38
* mpihelp_lshift( mpi_ptr_t wp, (sp + 4)
39
* mpi_ptr_t up, (sp + 8)
40
* mpi_size_t usize, (sp + 12)
41
* unsigned cnt) (sp + 16)
46
.globl C_SYMBOL_NAME(mpihelp_lshift)
47
C_SYMBOL_NAME(mpihelp_lshift:)
54
movl 20(%esp),%edi /* res_ptr */
55
movl 24(%esp),%esi /* s_ptr */
56
movl 28(%esp),%ebp /* size */
57
movl 32(%esp),%ecx /* cnt */
59
/* We can use faster code for shift-by-1 under certain conditions. */
64
jnc Lspecial /* jump if s_ptr + 1 >= res_ptr */
65
leal (%esi,%ebp,4),%eax
67
jnc Lspecial /* jump if res_ptr >= s_ptr + size */
70
leal -4(%edi,%ebp,4),%edi
71
leal -4(%esi,%ebp,4),%esi
76
shldl %cl,%edx,%eax /* compute carry limb */
77
pushl %eax /* push carry limb onto stack */
84
movl (%edi),%eax /* fetch destination cache line */
87
Loop: movl -28(%edi),%eax /* fetch destination cache line */
126
Loop2: movl (%esi),%eax
135
Lend2: shll %cl,%edx /* compute least significant limb */
136
movl %edx,(%edi) /* store it */
138
popl %eax /* pop carry limb */
146
/* We loop from least significant end of the arrays, which is only
147
permissable if the source and destination don't overlap, since the
148
function is documented to work for overlapping source and destination.
164
movl (%edi),%eax /* fetch destination cache line */
167
LLoop: movl 28(%edi),%eax /* fetch destination cache line */
198
leal 32(%esi),%esi /* use leal not to clobber carry */
204
sbbl %eax,%eax /* save carry in %eax */
207
addl %eax,%eax /* restore carry from eax */
208
LLoop2: movl %edx,%ebx
213
leal 4(%esi),%esi /* use leal not to clobber carry */
219
LLend2: addl %eax,%eax /* restore carry from eax */
220
LL1: movl %edx,(%edi) /* store last limb */