/****************************************************************************** * * * 96x32 MULTIPLY (UNSIGNED) * * 03/13/14 (dkc) * * * ******************************************************************************/ unsigned int carry(unsigned int a, unsigned int b, unsigned int sum); void newprod(unsigned int a0, unsigned int a1, unsigned int a2, unsigned int *product, unsigned int m0) { unsigned int a3,a4,a5,a6,a7,a8,m1,temp; unsigned int p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11; unsigned int s1,s2,s3,s4; unsigned int c2,c3,c4; a4=a0&0xffff; a3=a0>>16; a6=a1&0xffff; a5=a1>>16; a8=a2&0xffff; a7=a2>>16; m1=m0&0xffff; m0=m0>>16; p0=a3*m0; p1=a3*m1; p2=a4*m0; p3=a4*m1; p4=a5*m0; p5=a5*m1; p6=a6*m0; p7=a6*m1; p8=a7*m0; p9=a7*m1; p10=a8*m0; p11=a8*m1; s4=p11+(p10<<16); c4=carry(p11,(p10<<16),s4); temp=s4+(p9<<16); c4+=carry(s4,(p9<<16),temp); s4=temp; s3=p8+(p10>>16); c3=carry(p8,(p10>>16),s3); temp=s3+(p9>>16); c3+=carry(s3,(p9>>16),temp); s3=temp; temp=s3+p7; c3+=carry(s3,p7,temp); s3=temp; temp=s3+(p6<<16); c3+=carry(s3,(p6<<16),temp); s3=temp; temp=s3+(p5<<16); c3+=carry(s3,(p5<<16),temp); s3=temp; temp=s3+c4; c3+=carry(s3,c4,temp); s3=temp; s2=p4+(p6>>16); c2=carry(p4,(p6>>16),s2); temp=s2+(p5>>16); c2+=carry(s2,(p5>>16),temp); s2=temp; temp=s2+p3; c2+=carry(s2,p3,temp); s2=temp; temp=s2+(p2<<16); c2+=carry(s2,(p2<<16),temp); s2=temp; temp=s2+(p1<<16); c2+=carry(s2,(p1<<16),temp); s2=temp; temp=s2+c3; c2+=carry(s2,c3,temp); s2=temp; s1=p0+(p4>>16); temp=s1+(p1>>16); s1=temp+c2; *product=s1; *(product+1)=s2; *(product+2)=s3; *(product+3)=s4; return; }