WIP - bignum2 multiply

This commit is contained in:
Justin Ethier 2022-06-14 22:35:51 -04:00
parent 96ca2263af
commit 4833788223

View file

@ -2580,34 +2580,34 @@ static uint32_t bignum_digits_destructive_scale_down(uint32_t *start, uint32_t *
// } // }
// return carry; /* This would end up as most significant digit if it fit */ // return carry; /* This would end up as most significant digit if it fit */
//} //}
//
//static C_regparm void // TODO: static C_regparm void
//bignum_digits_multiply(C_word x, C_word y, C_word result) bignum_digits_multiply(object x, object y, object result)
//{ {
// C_uword product, uint32_t product,
// *xd = C_bignum_digits(x), *xd = C_bignum_digits(x),
// *yd = C_bignum_digits(y), *yd = C_bignum_digits(y),
// *rd = C_bignum_digits(result); *rd = C_bignum_digits(result);
// C_uhword carry, yj; uint16_t carry, yj;
// /* Lengths in halfwords */ /* Lengths in halfwords */
// int i, j, length_x = C_bignum_size(x) * 2, length_y = C_bignum_size(y) * 2; int i, j, length_x = C_bignum_size(x) * 2, length_y = C_bignum_size(y) * 2;
//
// /* From Hacker's Delight, Figure 8-1 (top part) */ /* From Hacker's Delight, Figure 8-1 (top part) */
// for (j = 0; j < length_y; ++j) { for (j = 0; j < length_y; ++j) {
// yj = C_uhword_ref(yd, j); yj = C_uhword_ref(yd, j);
// if (yj == 0) continue; if (yj == 0) continue;
// carry = 0; carry = 0;
// for (i = 0; i < length_x; ++i) { for (i = 0; i < length_x; ++i) {
// product = (C_uword)C_uhword_ref(xd, i) * yj + product = (C_uword)C_uhword_ref(xd, i) * yj +
// (C_uword)C_uhword_ref(rd, i + j) + carry; (C_uword)C_uhword_ref(rd, i + j) + carry;
// C_uhword_set(rd, i + j, product); C_uhword_set(rd, i + j, product);
// carry = C_BIGNUM_DIGIT_HI_HALF(product); carry = C_BIGNUM_DIGIT_HI_HALF(product);
// } }
// C_uhword_set(rd, j + length_x, carry); C_uhword_set(rd, j + length_x, carry);
// } }
//} }
//
//
///* "small" is either a number that fits a halfdigit, or a power of two */ ///* "small" is either a number that fits a halfdigit, or a power of two */
//static C_regparm void //static C_regparm void
//bignum_destructive_divide_unsigned_small(C_word **ptr, C_word x, C_word y, C_word *q, C_word *r) //bignum_destructive_divide_unsigned_small(C_word **ptr, C_word x, C_word y, C_word *q, C_word *r)