Texas Instruments MSP50C6xx User Manual

Page 324

Advertising
background image

Implementation Details

5-28

#include “cmm_macr.h”

constant int M1[4]={0x04CB,0x71FB,0x011F,0x0};

constant int M2[4]={0x85EB,0x8FD9,0x08FB,0x0};

cmm_func string_multiply(int *p,int lgp,int *m1,int lgm1,int *m2,int lgm2)

{

/* note: length of p,(lgp+2) must be at least (lgm1+2) + (lgm2+2) +1 */

/* this function string multiplies string m1 of length lgm1+2 by string m2 of

length lgm2+2, and puts the result into string p, of length lgp+2 */

int sign,i,j;

int *mm1,*mm2,*pp;

sign=1;

mm1=calloc(sizeof(int),lgm1+2);

mm2=calloc(sizeof(int),lgm2+2);

pp =calloc(sizeof(int),lgp+2);

if(test_string(m1,0,lgm1,LTS_N))

{

neg_string(mm1,m1,lgm1);

sign*=–1;

}

else

copy_string(mm1,m1,lgm1);

if(test_string(m2,0,lgm2,LTS_N))

{

neg_string(mm2,m2,lgm2);

sign*=–1;

}

else

copy_string(mm2,m2,lgm2);

for(j=0;j<lgp+2;j++)

p[j]=0;

for(i=0;i<lgm2+2;i++)

{

for(j=0;j<lgp+2;j++)

pp[j]=0;

umul_string(&pp[i],mm1,mm2[i],lgm1);

Advertising