1
/* i80386 rshift, lshift
2
* Copyright (C) 1998 Free Software Foundation, Inc.
3
* Copyright (C) 1992, 1994 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)
45
.globl C_SYMBOL_NAME(mpihelp_lshift)
46
C_SYMBOL_NAME(mpihelp_lshift:)
51
movl 16(%esp),%edi /* res_ptr */
52
movl 20(%esp),%esi /* s_ptr */
53
movl 24(%esp),%edx /* size */
54
movl 28(%esp),%ecx /* cnt */
56
subl $4,%esi /* adjust s_ptr */
58
movl (%esi,%edx,4),%ebx /* read most significant limb */
60
shldl %cl,%ebx,%eax /* compute carry limb */
63
pushl %eax /* push carry limb onto stack */
65
jnz L1 /* enter loop in the middle */
69
Loop: movl (%esi,%edx,4),%ebx /* load next lower limb */
70
shldl %cl,%ebx,%eax /* compute result limb */
71
movl %eax,(%edi,%edx,4) /* store it */
73
L1: movl (%esi,%edx,4),%eax
75
movl %ebx,(%edi,%edx,4)
79
shll %cl,%eax /* compute least significant limb */
80
movl %eax,(%edi) /* store it */
82
popl %eax /* pop carry limb */
89
Lend: shll %cl,%ebx /* compute least significant limb */
90
movl %ebx,(%edi) /* store it */
99
* mpihelp_rshift( mpi_ptr_t wp, (sp + 4)
100
* mpi_ptr_t up, (sp + 8)
101
* mpi_size_t usize, (sp + 12)
102
* unsigned cnt) (sp + 16)
107
.globl C_SYMBOL_NAME(mpihelp_rshift)
108
C_SYMBOL_NAME(mpihelp_rshift:)
113
movl 16(%esp),%edi /* wp */
114
movl 20(%esp),%esi /* up */
115
movl 24(%esp),%edx /* usize */
116
movl 28(%esp),%ecx /* cnt */
118
leal -4(%edi,%edx,4),%edi
119
leal (%esi,%edx,4),%esi
122
movl (%esi,%edx,4),%ebx /* read least significant limb */
124
shrdl %cl,%ebx,%eax /* compute carry limb */
127
pushl %eax /* push carry limb onto stack */
129
jnz L2 /* enter loop in the middle */
133
Loop2: movl (%esi,%edx,4),%ebx /* load next higher limb */
134
shrdl %cl,%ebx,%eax /* compute result limb */
135
movl %eax,(%edi,%edx,4) /* store it */
137
L2: movl (%esi,%edx,4),%eax
139
movl %ebx,(%edi,%edx,4)
143
shrl %cl,%eax /* compute most significant limb */
144
movl %eax,(%edi) /* store it */
146
popl %eax /* pop carry limb */
153
Lend2: shrl %cl,%ebx /* compute most significant limb */
154
movl %ebx,(%edi) /* store it */