1 dnl Intel Pentium-4 mpn_sub_n -- mpn subtraction.
3 dnl Copyright 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 P4 Willamette, Northwood: 4.0 cycles/limb if dst!=src1 and dst!=src2
24 C 6.0 cycles/limb if dst==src1 or dst==src2
25 C P4 Prescott: >= 5 cycles/limb
28 C mp_limb_t mpn_sub_n (mp_ptr dst, mp_srcptr src1, mp_srcptr src2,
30 C mp_limb_t mpn_sub_nc (mp_ptr dst, mp_srcptr src1, mp_srcptr src2,
31 C mp_size_t size, mp_limb_t carry);
33 C The main loop code is 2x unrolled so that the carry bit can alternate
34 C between mm0 and mm1.
36 defframe(PARAM_CARRY,20)
37 defframe(PARAM_SIZE, 16)
38 defframe(PARAM_SRC2, 12)
39 defframe(PARAM_SRC1, 8)
40 defframe(PARAM_DST, 4)
42 dnl re-use parameter space
43 define(SAVE_EBX,`PARAM_SRC1')
51 movd PARAM_CARRY, %mm0
67 leal (%eax,%ecx,4), %eax C src1 end
68 leal (%ebx,%ecx,4), %ebx C src2 end
69 leal (%edx,%ecx,4), %edx C dst end
75 C ecx counter, limbs, negative
79 movd (%eax,%ecx,4), %mm1
80 movd (%ebx,%ecx,4), %mm2
84 movd %mm1, (%edx,%ecx,4)
91 movd (%eax,%ecx,4), %mm0
92 movd (%ebx,%ecx,4), %mm2
96 movd %mm0, (%edx,%ecx,4)