1 /* i80386 __mpn_rshift --
2 Copyright (C) 1992,1994,1997-2000,2005,2010 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 Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 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 Lesser General Public
13 License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with the GNU MP Library; see the file COPYING.LIB. If not,
17 see <http://www.gnu.org/licenses/>. */
20 #include "asm-syntax.h"
24 #define PARMS LINKAGE+12 /* space for 3 saved regs */
26 #define S RES+PTR_SIZE
27 #define SIZE S+PTR_SIZE
31 ENTRY (BP_SYM (__mpn_rshift))
35 cfi_adjust_cfa_offset (4)
37 cfi_adjust_cfa_offset (4)
39 cfi_adjust_cfa_offset (4)
42 cfi_rel_offset (edi, 8)
44 cfi_rel_offset (esi, 4)
47 #if __BOUNDED_POINTERS__
48 shll $2, %edx /* convert limbs to bytes */
49 CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %edx)
50 CHECK_BOUNDS_BOTH_WIDE (%esi, S(%esp), %edx)
53 leal -4(%edi,%edx,4),%edi
54 leal (%esi,%edx,4),%esi
57 movl (%esi,%edx,4),%ebx /* read least significant limb */
58 cfi_rel_offset (ebx, 0)
61 shrdl %cl,%ebx,%eax /* compute carry limb */
64 pushl %eax /* push carry limb onto stack */
65 cfi_adjust_cfa_offset (4)
67 jnz L(1) /* enter loop in the middle */
71 L(oop): movl (%esi,%edx,4),%ebx /* load next higher limb */
72 shrdl %cl,%ebx,%eax /* compute result limb */
73 movl %eax,(%edi,%edx,4) /* store it */
75 L(1): movl (%esi,%edx,4),%eax
77 movl %ebx,(%edi,%edx,4)
81 shrl %cl,%eax /* compute most significant limb */
82 movl %eax,(%edi) /* store it */
84 popl %eax /* pop carry limb */
85 cfi_adjust_cfa_offset (-4)
88 cfi_adjust_cfa_offset (-4)
91 cfi_adjust_cfa_offset (-4)
94 cfi_adjust_cfa_offset (-4)
101 L(end): shrl %cl,%ebx /* compute most significant limb */
102 movl %ebx,(%edi) /* store it */
105 cfi_adjust_cfa_offset (-4)
108 cfi_adjust_cfa_offset (-4)
111 cfi_adjust_cfa_offset (-4)
116 END (BP_SYM (__mpn_rshift))