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"
39
* mpihelp_rshift( mpi_ptr_t wp, (sp + 4)
40
* mpi_ptr_t up, (sp + 8)
41
* mpi_size_t usize, (sp + 12)
42
* unsigned cnt) (sp + 16)
47
.globl C_SYMBOL_NAME(mpihelp_rshift)
48
C_SYMBOL_NAME(mpihelp_rshift:)
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 Rspecial /* jump if res_ptr + 1 >= s_ptr */
65
leal (%edi,%ebp,4),%eax
67
jnc Rspecial /* jump if s_ptr >= res_ptr + size */
73
shrdl %cl,%edx,%eax /* compute carry limb */
74
pushl %eax /* push carry limb onto stack */
81
movl (%edi),%eax /* fetch destination cache line */
84
Roop: movl 28(%edi),%eax /* fetch destination cache line */
123
Roop2: movl (%esi),%eax
124
shrdl %cl,%eax,%edx /* compute result limb */
132
Rend2: shrl %cl,%edx /* compute most significant limb */
133
movl %edx,(%edi) /* store it */
135
popl %eax /* pop carry limb */
143
/* We loop from least significant end of the arrays, which is only
144
permissable if the source and destination don't overlap, since the
145
function is documented to work for overlapping source and destination.
149
leal -4(%edi,%ebp,4),%edi
150
leal -4(%esi,%ebp,4),%esi
164
movl (%edi),%eax /* fetch destination cache line */
167
RLoop: 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
RLoop2: movl %edx,%ebx
213
leal -4(%esi),%esi /* use leal not to clobber carry */
219
RLend2: addl %eax,%eax /* restore carry from eax */
220
RL1: movl %edx,(%edi) /* store last limb */