1dnl x86 mpn_rshift -- mpn right shift. 2 3dnl Copyright 1992, 1994, 1996, 1999, 2000, 2001, 2002 Free Software 4dnl Foundation, Inc. 5dnl 6dnl This file is part of the GNU MP Library. 7dnl 8dnl The GNU MP Library is free software; you can redistribute it and/or 9dnl modify it under the terms of the GNU Lesser General Public License as 10dnl published by the Free Software Foundation; either version 3 of the 11dnl License, or (at your option) any later version. 12dnl 13dnl The GNU MP Library is distributed in the hope that it will be useful, 14dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 15dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16dnl Lesser General Public License for more details. 17dnl 18dnl You should have received a copy of the GNU Lesser General Public License 19dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 20 21include(`../config.m4') 22 23 24C cycles/limb 25C P54: 7.5 26C P55: 7.0 27C P6: 2.5 28C K6: 4.5 29C K7: 5.0 30C P4: 16.5 31 32 33C mp_limb_t mpn_rshift (mp_ptr dst, mp_srcptr src, mp_size_t size, 34C unsigned shift); 35 36defframe(PARAM_SHIFT,16) 37defframe(PARAM_SIZE, 12) 38defframe(PARAM_SRC, 8) 39defframe(PARAM_DST, 4) 40 41 TEXT 42 ALIGN(8) 43PROLOGUE(mpn_rshift) 44 45 pushl %edi 46 pushl %esi 47 pushl %ebx 48deflit(`FRAME',12) 49 50 movl PARAM_DST,%edi 51 movl PARAM_SRC,%esi 52 movl PARAM_SIZE,%edx 53 movl PARAM_SHIFT,%ecx 54 55 leal -4(%edi,%edx,4),%edi 56 leal (%esi,%edx,4),%esi 57 negl %edx 58 59 movl (%esi,%edx,4),%ebx C read least significant limb 60 xorl %eax,%eax 61 shrdl( %cl, %ebx, %eax) C compute carry limb 62 incl %edx 63 jz L(end) 64 pushl %eax C push carry limb onto stack 65 testb $1,%dl 66 jnz L(1) C enter loop in the middle 67 movl %ebx,%eax 68 69 ALIGN(8) 70L(oop): movl (%esi,%edx,4),%ebx C load next higher limb 71 shrdl( %cl, %ebx, %eax) C compute result limb 72 movl %eax,(%edi,%edx,4) C store it 73 incl %edx 74L(1): movl (%esi,%edx,4),%eax 75 shrdl( %cl, %eax, %ebx) 76 movl %ebx,(%edi,%edx,4) 77 incl %edx 78 jnz L(oop) 79 80 shrl %cl,%eax C compute most significant limb 81 movl %eax,(%edi) C store it 82 83 popl %eax C pop carry limb 84 85 popl %ebx 86 popl %esi 87 popl %edi 88 ret 89 90L(end): shrl %cl,%ebx C compute most significant limb 91 movl %ebx,(%edi) C store it 92 93 popl %ebx 94 popl %esi 95 popl %edi 96 ret 97 98EPILOGUE() 99