1 /* Pentium optimized __mpn_rshift --
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_rshift)
36 C_SYMBOL_NAME(__mpn_rshift:)
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 res_ptr + 1 >= s_ptr */
53 leal (%edi,%ebp,4),%eax
55 jnc Lspecial /* jump if s_ptr >= res_ptr + size */
61 shrdl %cl,%edx,%eax /* compute carry limb */
62 pushl %eax /* push carry limb onto stack */
69 movl (%edi),%eax /* fetch destination cache line */
72 Loop: movl 28(%edi),%eax /* fetch destination cache line */
111 Loop2: movl (%esi),%eax
112 shrdl %cl,%eax,%edx /* compute result limb */
120 Lend2: 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 permissable 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 */
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 */