Annotation of OpenXM_contrib/gmp/mpn/x86/mod_1.asm, Revision 1.1.1.2
1.1 maekawa 1: dnl x86 mpn_mod_1 -- mpn by limb remainder.
2:
1.1.1.2 ! ohara 3: dnl Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
1.1 maekawa 4: dnl
5: dnl This file is part of the GNU MP Library.
6: dnl
7: dnl The GNU MP Library is free software; you can redistribute it and/or
8: dnl modify it under the terms of the GNU Lesser General Public License as
9: dnl published by the Free Software Foundation; either version 2.1 of the
10: dnl License, or (at your option) any later version.
11: dnl
12: dnl The GNU MP Library is distributed in the hope that it will be useful,
13: dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14: dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: dnl Lesser General Public License for more details.
16: dnl
17: dnl You should have received a copy of the GNU Lesser General Public
18: dnl License along with the GNU MP Library; see the file COPYING.LIB. If
19: dnl not, write to the Free Software Foundation, Inc., 59 Temple Place -
20: dnl Suite 330, Boston, MA 02111-1307, USA.
21:
1.1.1.2 ! ohara 22: include(`../config.m4')
1.1 maekawa 23:
24:
1.1.1.2 ! ohara 25: C cycles/limb
! 26: C 486 42 approx, maybe
! 27: C P5 44
! 28: C P6 39
! 29: C K6 20
! 30: C K7 41
! 31: C P4 58
1.1 maekawa 32:
33:
34: C mp_limb_t mpn_mod_1 (mp_srcptr src, mp_size_t size, mp_limb_t divisor);
35: C mp_limb_t mpn_mod_1c (mp_srcptr src, mp_size_t size, mp_limb_t divisor,
36: C mp_limb_t carry);
37: C
38: C Divide src,size by divisor and return the remainder. The quotient is
39: C discarded.
40: C
41: C See mpn/x86/divrem_1.asm for some comments.
42:
43: defframe(PARAM_CARRY, 16)
44: defframe(PARAM_DIVISOR,12)
45: defframe(PARAM_SIZE, 8)
46: defframe(PARAM_SRC, 4)
47:
1.1.1.2 ! ohara 48: TEXT
1.1 maekawa 49: ALIGN(16)
50:
51: PROLOGUE(mpn_mod_1c)
52: deflit(`FRAME',0)
53:
54: movl PARAM_SIZE, %ecx
55: pushl %ebx FRAME_pushl()
56:
57: movl PARAM_SRC, %ebx
58: pushl %esi FRAME_pushl()
59:
60: movl PARAM_DIVISOR, %esi
61: orl %ecx, %ecx
62:
63: movl PARAM_CARRY, %edx
1.1.1.2 ! ohara 64: jnz L(top)
1.1 maekawa 65:
66: popl %esi
67: movl %edx, %eax
68:
69: popl %ebx
70:
71: ret
72:
73: EPILOGUE()
74:
75:
76: PROLOGUE(mpn_mod_1)
77: deflit(`FRAME',0)
78:
79: movl PARAM_SIZE, %ecx
80: pushl %ebx FRAME_pushl()
81:
82: movl PARAM_SRC, %ebx
83: pushl %esi FRAME_pushl()
84:
85: orl %ecx, %ecx
86: jz L(done_zero)
87:
88: movl PARAM_DIVISOR, %esi
89: movl -4(%ebx,%ecx,4), %eax C src high limb
90:
91: cmpl %esi, %eax
92:
93: sbbl %edx, %edx C -1 if high<divisor
94:
95: addl %edx, %ecx C skip one division if high<divisor
96: jz L(done_eax)
97:
98: andl %eax, %edx C carry if high<divisor
99:
100:
101: L(top):
102: C eax scratch (quotient)
103: C ebx src
104: C ecx counter
105: C edx carry (remainder)
106: C esi divisor
107: C edi
108: C ebp
109:
110: movl -4(%ebx,%ecx,4), %eax
111:
112: divl %esi
113:
114: loop_or_decljnz L(top)
115:
116:
117: movl %edx, %eax
118: L(done_eax):
119: popl %esi
120:
121: popl %ebx
122:
123: ret
124:
125:
126: L(done_zero):
127: popl %esi
128: xorl %eax, %eax
129:
130: popl %ebx
131:
132: ret
133:
134:
135: EPILOGUE()
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>