1 /* Copyright Digital Equipment Corporation & INRIA 1988, 1989 */
2 /* Last modified_on Fri Mar 30 4:13:47 GMT+2:00 1990 by shand */
3 /* modified_on Mon Mar 26 18:09:25 GMT+2:00 1990 by herve */
6 /* bnMult.c: a piece of the bignum kernel written in C */
9 /***************************************/
16 static char copyright[]="@(#)bnMult.c: copyright Digital Equipment Corporation & INRIA 1988, 1989, 1990\n";
18 BigNumCarry BnnMultiply (pp, pl, mm, ml, nn, nl)
20 register BigNum pp, nn;
22 register BigNumLength pl, nl;
26 * Performs the product:
30 * Q div BB => CarryOut
32 * Returns the CarryOut.
35 * Size(P) >= Size(M) + Size(N),
42 /* Multiply one digit at a time */
44 /* the following code give higher performance squaring.
45 ** Unfortunately for small nl, procedure call overheads kills it
48 /* Squaring code provoke a mips optimizer bug in V1.31 */
49 if (mm == nn && ml == nl && nl > 6)
52 /* special case of squaring */
55 register BigNumDigit n = *nn;
56 c += BnnMultiplyDigit(pp, pl, nn, 1, n);
58 c += BnnAdd(pp, pl, nn, 1, 0);
61 c += BnnMultiplyDigit(pp-1, pl+1, nn, nl, n+n+n_prev);
62 n_prev = ((long) n) < 0;
67 for (c = 0; nl-- > 0; pp++, nn++, pl--)
68 c += BnnMultiplyDigit (pp, pl, mm, ml, *nn);