1 dnl Generic x86 mpn_mod_34lsub1 -- mpn remainder modulo 2^24-1.
3 dnl Copyright 2000, 2001, 2002, 2004 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')
31 C mp_limb_t mpn_mod_34lsub1 (mp_srcptr src, mp_size_t size)
34 defframe(PARAM_SIZE, 8)
35 defframe(PARAM_SRC, 4)
37 dnl re-use parameter space
38 define(SAVE_EBX, `PARAM_SRC')
42 PROLOGUE(mpn_mod_34lsub1)
56 shrl $24, %eax C src[0] low
58 andl $0xFFFFFF, %edx C src[0] high
63 shrl $16, %edx C src[1] high
66 shll $8, %ecx C src[1] low
82 movl %ebx, SAVE_EBX C and arrange 16-byte loop alignment
85 pushl %esi FRAME_pushl()
88 pushl %edi FRAME_pushl()
89 xorl %eax, %eax C and clear carry flag
113 C ecx is -2, -1 or 0 representing 0, 1 or 2 more limbs, respectively
115 movl $0xFFFFFFFF, %edi
120 movl $0xFFFFFF00, %edi
125 movl $0xFFFF0000, %edi
137 sbbl %ecx, %ecx C carry
138 movl %eax, %edx C 0mod3
140 shrl $24, %eax C 0mod3 high
141 andl %edi, %ecx C carry masked
143 subl %ecx, %eax C apply carry
144 movl %ebx, %edi C 1mod3
146 shrl $16, %ebx C 1mod3 high
147 andl $0x00FFFFFF, %edx C 0mod3 low
149 addl %edx, %eax C apply 0mod3 low
152 shll $8, %edi C 1mod3 low
153 addl %ebx, %eax C apply 1mod3 high
155 addl %edi, %eax C apply 1mod3 low
156 movl %esi, %edx C 2mod3
158 shrl $8, %esi C 2mod3 high
159 andl $0xFF, %edx C 2mod3 low
161 shll $16, %edx C 2mod3 low
162 addl %esi, %eax C apply 2mod3 high
164 addl %edx, %eax C apply 2mod3 low
165 popl %edi FRAME_popl()
168 popl %esi FRAME_popl()