Annotation of OpenXM_contrib/gmp/mpn/x86/pentium/mul_1.asm, Revision 1.1.1.2
1.1 maekawa 1: dnl Intel Pentium mpn_mul_1 -- mpn by limb multiplication.
2:
1.1.1.2 ! ohara 3: dnl Copyright 1992, 1994, 1996, 1999, 2000, 2002 Free Software Foundation,
1.1 maekawa 4: dnl Inc.
5: dnl
6: dnl This file is part of the GNU MP Library.
7: dnl
8: dnl The GNU MP Library is free software; you can redistribute it and/or
9: dnl modify it under the terms of the GNU Lesser General Public License as
10: dnl published by the Free Software Foundation; either version 2.1 of the
11: dnl License, or (at your option) any later version.
12: dnl
13: dnl The GNU MP Library is distributed in the hope that it will be useful,
14: dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15: dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: dnl Lesser General Public License for more details.
17: dnl
18: dnl You should have received a copy of the GNU Lesser General Public
19: dnl License along with the GNU MP Library; see the file COPYING.LIB. If
20: dnl not, write to the Free Software Foundation, Inc., 59 Temple Place -
21: dnl Suite 330, Boston, MA 02111-1307, USA. */
22:
23: include(`../config.m4')
24:
25:
1.1.1.2 ! ohara 26: C P5: 12.0 cycles/limb
! 27:
! 28:
1.1 maekawa 29: C mp_limb_t mpn_mul_1 (mp_ptr dst, mp_srcptr src, mp_size_t size,
30: C mp_limb_t multiplier);
1.1.1.2 ! ohara 31: C mp_limb_t mpn_mul_1c (mp_ptr dst, mp_srcptr src, mp_size_t size,
! 32: C mp_limb_t multiplier, mp_limb_t carry);
! 33: C
1.1 maekawa 34:
1.1.1.2 ! ohara 35: defframe(PARAM_CARRY, 20)
1.1 maekawa 36: defframe(PARAM_MULTIPLIER,16)
37: defframe(PARAM_SIZE, 12)
38: defframe(PARAM_SRC, 8)
39: defframe(PARAM_DST, 4)
40:
1.1.1.2 ! ohara 41: TEXT
! 42: ALIGN(8)
! 43: PROLOGUE(mpn_mul_1c)
! 44: deflit(`FRAME',0)
! 45:
! 46: movl PARAM_CARRY, %ecx
! 47: pushl %esi FRAME_pushl()
! 48:
! 49: jmp L(start_1c)
! 50:
! 51: EPILOGUE()
! 52:
! 53:
1.1 maekawa 54: ALIGN(8)
55: PROLOGUE(mpn_mul_1)
1.1.1.2 ! ohara 56: deflit(`FRAME',0)
1.1 maekawa 57:
1.1.1.2 ! ohara 58: xorl %ecx, %ecx
! 59: pushl %esi FRAME_pushl()
1.1 maekawa 60:
1.1.1.2 ! ohara 61: L(start_1c):
1.1 maekawa 62: movl PARAM_SRC, %esi
1.1.1.2 ! ohara 63: movl PARAM_SIZE, %eax
! 64:
! 65: shrl %eax
! 66: jnz L(two_or_more)
1.1 maekawa 67:
68:
1.1.1.2 ! ohara 69: C one limb only
1.1 maekawa 70:
1.1.1.2 ! ohara 71: movl (%esi), %eax
! 72:
! 73: mull PARAM_MULTIPLIER
! 74:
! 75: addl %eax, %ecx
! 76: movl PARAM_DST, %eax
! 77:
! 78: adcl $0, %edx
! 79: popl %esi
! 80:
! 81: movl %ecx, (%eax)
! 82: movl %edx, %eax
! 83:
! 84: ret
! 85:
! 86:
! 87: L(two_or_more):
! 88: C eax size/2
! 89: C ebx
! 90: C ecx carry
! 91: C edx
! 92: C esi src
! 93: C edi
! 94: C ebp
! 95:
! 96: pushl %edi FRAME_pushl()
! 97: pushl %ebx FRAME_pushl()
! 98:
! 99: movl PARAM_DST, %edi
! 100: leal -1(%eax), %ebx C size/2-1
1.1 maekawa 101:
1.1.1.2 ! ohara 102: notl %ebx C -size, preserve carry
1.1 maekawa 103:
1.1.1.2 ! ohara 104: leal (%esi,%eax,8), %esi C src end
! 105: leal (%edi,%eax,8), %edi C dst end
1.1 maekawa 106:
1.1.1.2 ! ohara 107: pushl %ebp FRAME_pushl()
! 108: jnc L(top)
1.1 maekawa 109:
1.1.1.2 ! ohara 110:
! 111: C size was odd, process one limb separately
! 112:
! 113: movl (%esi,%ebx,8), %eax
! 114: addl $4, %esi
! 115:
! 116: mull PARAM_MULTIPLIER
! 117:
! 118: addl %ecx, %eax
! 119: movl %edx, %ecx
! 120:
! 121: movl %eax, (%edi,%ebx,8)
! 122: leal 4(%edi), %edi
! 123:
! 124:
! 125: L(top):
! 126: C eax
! 127: C ebx counter, negative
! 128: C ecx carry
! 129: C edx
! 130: C esi src end
! 131: C edi dst end
! 132: C ebp
! 133:
! 134: adcl $0, %ecx
! 135: movl (%esi,%ebx,8), %eax
! 136:
! 137: mull PARAM_MULTIPLIER
! 138:
! 139: movl %edx, %ebp
! 140: addl %eax, %ecx
! 141:
! 142: adcl $0, %ebp
! 143: movl 4(%esi,%ebx,8), %eax
! 144:
! 145: mull PARAM_MULTIPLIER
! 146:
! 147: movl %ecx, (%edi,%ebx,8)
! 148: addl %ebp, %eax
! 149:
! 150: movl %eax, 4(%edi,%ebx,8)
! 151: incl %ebx
! 152:
! 153: movl %edx, %ecx
! 154: jnz L(top)
! 155:
! 156:
! 157: adcl $0, %ecx
1.1 maekawa 158: popl %ebp
1.1.1.2 ! ohara 159:
! 160: movl %ecx, %eax
1.1 maekawa 161: popl %ebx
1.1.1.2 ! ohara 162:
1.1 maekawa 163: popl %edi
1.1.1.2 ! ohara 164: popl %esi
! 165:
1.1 maekawa 166: ret
167:
168: EPILOGUE()
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>