1 /* Pentium optimized __mpn_lshift --
3 Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by
9 the Free Software Foundation; either version 2 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 Library General Public
15 License for more details.
17 You should have received a copy of the GNU Library 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. */
31 #include "asm-syntax.h"
35 .globl C_SYMBOL_NAME(__mpn_lshift)
36 C_SYMBOL_NAME(__mpn_lshift:)
42 movl 20(%esp),%edi /* res_ptr */
43 movl 24(%esp),%esi /* s_ptr */
44 movl 28(%esp),%ebp /* size */
45 movl 32(%esp),%ecx /* cnt */
47 /* We can use faster code for shift-by-1 under certain conditions. */
52 jnc Lspecial /* jump if s_ptr + 1 >= res_ptr */
53 leal (%esi,%ebp,4),%eax
55 jnc Lspecial /* jump if res_ptr >= s_ptr + size */
58 leal -4(%edi,%ebp,4),%edi
59 leal -4(%esi,%ebp,4),%esi
64 shldl %cl,%edx,%eax /* compute carry limb */
65 pushl %eax /* push carry limb onto stack */
72 movl (%edi),%eax /* fetch destination cache line */
75 Loop: movl -28(%edi),%eax /* fetch destination cache line */
114 Loop2: movl (%esi),%eax
123 Lend2: shll %cl,%edx /* compute least significant limb */
124 movl %edx,(%edi) /* store it */
126 popl %eax /* pop carry limb */
134 /* We loop from least significant end of the arrays, which is only
135 permissable if the source and destination don't overlap, since the
136 function is documented to work for overlapping source and destination.
152 movl (%edi),%eax /* fetch destination cache line */
155 LLoop: movl 28(%edi),%eax /* fetch destination cache line */
186 leal 32(%esi),%esi /* use leal not to clobber carry */
192 sbbl %eax,%eax /* save carry in %eax */
195 addl %eax,%eax /* restore carry from eax */
196 LLoop2: movl %edx,%ebx
201 leal 4(%esi),%esi /* use leal not to clobber carry */
207 LLend2: addl %eax,%eax /* restore carry from eax */
208 LL1: movl %edx,(%edi) /* store last limb */