c - converting base 4 code to letters -


im working on assmebler project have , need translate binary machine code have "weird" 4 base code example if binary code "0000-10-01-00" should translate "aacba"

00=a

01=b

10=c

11=d

i have managed translate code 4 base code dont know how continue there or if right way it,...

adding code below

void inttobase4 (unsigned int *num) {   int d[7];   int j,i=0;   double x=0;   while((*num)>0)   {     d[i]=(*num)%4;     i++;     (*num)=(*num)/4;   }   for(x=0,j=i-1; j>=0; j--)   {     x += d[j]*pow(10,j);   }   (*num)=(unsigned int)x; } 

i've included little 32-bit num letter converter grasp basics. works single "32-bit number" @ time. use basis array based solution have half way done in example, or change type bigger, or whatever. should show need do:

void inttobase4 (uint32_t num, char *outstring) {   // there 16 digits per num in example   for(int i=0; i<16; i++)   {      // grab lowest 2 bits , convert letter.     *outstring++ = (num & 0x03) + 'a';      // shift next 2 bits low     num >>= 2;   }   // nul terminate string.   *outstring = '\0'; } 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -