1
/* mpn_addmul_1, mpn_submul_1 -- multiply the S1_SIZE long limb vector
2
pointed to by S1_PTR by S2_LIMB, add/subtract the S1_SIZE least
3
significant limbs of the product to/from the limb vector pointed to by
4
RES_PTR. Return the most significant limb of the product, adjusted for
5
carry-out from the addition.
7
Copyright 1992, 1993, 1994, 1996, 2000 Free Software Foundation, Inc.
9
This file is part of the GNU MP Library.
11
The GNU MP Library is free software; you can redistribute it and/or modify
12
it under the terms of the GNU Lesser General Public License as published by
13
the Free Software Foundation; either version 2.1 of the License, or (at your
14
option) any later version.
16
The GNU MP Library is distributed in the hope that it will be useful, but
17
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19
License for more details.
21
You should have received a copy of the GNU Lesser General Public License
22
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
23
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24
MA 02111-1307, USA. */
31
#ifdef OPERATION_addmul_1
32
#define FUNCTION mpn_addmul_1
33
#define VARIATION prod_low = x + prod_low; cy_limb += (prod_low < x);
36
#ifdef OPERATION_submul_1
37
#define FUNCTION mpn_submul_1
38
#define VARIATION prod_low = x - prod_low; cy_limb += (prod_low > x);
42
Error, error, need OPERATION_addmul_1 or OPERATION_submul_1
47
FUNCTION (register mp_ptr res_ptr,
48
register mp_srcptr s1_ptr,
50
register mp_limb_t s2_limb)
52
register mp_limb_t cy_limb;
54
register mp_limb_t prod_high, prod_low;
57
ASSERT (s1_size >= 1);
58
ASSERT (MPN_SAME_OR_SEPARATE_P (res_ptr, s1_ptr, s1_size));
60
/* The loop counter and index J goes from -SIZE to -1. This way
61
the loop becomes faster. */
64
/* Offset the base pointers to compensate for the negative indices. */
71
umul_ppmm (prod_high, prod_low, s1_ptr[j], s2_limb);
74
cy_limb = (prod_low < cy_limb) + prod_high;
78
res_ptr[j] = prod_low;