1 dnl Intel P5 mpn_mod_34lsub1 -- mpn remainder modulo 2**24-1.
3 dnl Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
5 dnl This file is part of the GNU MP Library.
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 3 of the
10 dnl License, or (at your option) any later version.
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.
17 dnl You should have received a copy of the GNU Lesser General Public License
18 dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
20 include(`../config.m4')
23 C P5: 1.66 cycles/limb
26 C mp_limb_t mpn_mod_34lsub1 (mp_srcptr src, mp_size_t size)
29 defframe(PARAM_SIZE, 8)
30 defframe(PARAM_SRC, 4)
34 PROLOGUE(mpn_mod_34lsub1)
77 pushl %ebx FRAME_pushl()
78 pushl %esi FRAME_pushl()
80 pushl %edi FRAME_pushl()
81 pushl %ebp FRAME_pushl()
83 xorl %esi, %esi C 0mod3
84 xorl %edi, %edi C 1mod3
86 xorl %ebp, %ebp C 2mod3, and clear carry
113 C ecx is -2, -1 or 0, representing 0, 1 or 2 more limbs, respectively
115 movl $0xFFFFFFFF, %ebx C mask
118 js L(combine) C 0 more
121 movl $0xFFFFFF00, %ebx
126 js L(combine) C 1 more
129 movl $0xFFFF0000, %ebx
144 sbbl %ecx, %ecx C carry
145 movl %esi, %eax C 0mod3
147 andl %ebx, %ecx C masked for position
148 andl $0xFFFFFF, %eax C 0mod3 low
150 shrl $24, %esi C 0mod3 high
151 subl %ecx, %eax C apply carry
153 addl %esi, %eax C apply 0mod3
154 movl %edi, %ebx C 1mod3
156 shrl $16, %edi C 1mod3 high
157 andl $0x0000FFFF, %ebx
159 shll $8, %ebx C 1mod3 low
160 addl %edi, %eax C apply 1mod3 high
162 addl %ebx, %eax C apply 1mod3 low
163 movl %ebp, %ebx C 2mod3
165 shrl $8, %ebp C 2mod3 high
168 shll $16, %ebx C 2mod3 low
169 addl %ebp, %eax C apply 2mod3 high
171 addl %ebx, %eax C apply 2mod3 low