/* * 32 bit by 32 bit multiplication primitives. * Jack Lacy * Copyright (c) 1993 Bell Laboratories */ #include "lib9.h" #include #define add64(sh, sl, ah, al, bh, bl) {{\ ulong __c;\ __c = (al) + (bl);\ (sh) = (ah) + (bh);\ if(__c < (al))\ (sh)++;\ (sl) = __c;\ }} #define add32(sh, sl, al, bl) {{\ ulong __c;\ __c = (al) + (bl);\ if(__c < (al))\ (sh) = 1;\ else\ (sh) = 0;\ (sl) = __c;\ }} ulong umult(ulong, ulong, ulong*); #define mul32(dhi, dlo, m1, m2) dlo = umult(m1, m2, &dhi) NumType LMULT(NumType *dst, NumType m, NumType *src, int N) { ulong sumh, suml; NumType carry, *ap, *cp, mm; int i; ap = src; cp = dst; mm = m; carry = 0; for (i=0; i