1 /* Pentium optimized __mpn_rshift --
2 Copyright (C) 1992, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
3 This file is part of the GNU MP Library.
5 The GNU MP Library is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
10 The GNU MP Library is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with the GNU MP Library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 MA 02111-1307, USA. */
29 #include "asm-syntax.h"
33 .globl C_SYMBOL_NAME(__mpn_rshift)
34 C_SYMBOL_NAME(__mpn_rshift:)
40 movl 20(%esp),%edi /* res_ptr */
41 movl 24(%esp),%esi /* s_ptr */
42 movl 28(%esp),%ebp /* size */
43 movl 32(%esp),%ecx /* cnt */
45 /* We can use faster code for shift-by-1 under certain conditions. */
50 jnc L(special) /* jump if res_ptr + 1 >= s_ptr */
51 leal (%edi,%ebp,4),%eax
53 jnc L(special) /* jump if s_ptr >= res_ptr + size */
59 shrdl %cl,%edx,%eax /* compute carry limb */
60 pushl %eax /* push carry limb onto stack */
67 movl (%edi),%eax /* fetch destination cache line */
70 L(oop): movl 28(%edi),%eax /* fetch destination cache line */
111 shrdl %cl,%eax,%edx /* compute result limb */
120 shrl %cl,%edx /* compute most significant limb */
121 movl %edx,(%edi) /* store it */
123 popl %eax /* pop carry limb */
131 /* We loop from least significant end of the arrays, which is only
132 permissible if the source and destination don't overlap, since the
133 function is documented to work for overlapping source and destination.
137 leal -4(%edi,%ebp,4),%edi
138 leal -4(%esi,%ebp,4),%esi
152 movl (%edi),%eax /* fetch destination cache line */
156 movl -28(%edi),%eax /* fetch destination cache line */
187 leal -32(%esi),%esi /* use leal not to clobber carry */
194 sbbl %eax,%eax /* save carry in %eax */
197 addl %eax,%eax /* restore carry from eax */
204 leal -4(%esi),%esi /* use leal not to clobber carry */
211 addl %eax,%eax /* restore carry from eax */
212 L(L1): movl %edx,(%edi) /* store last limb */