I am receiving UART bytes (8 bit long) and I want every 4 bytes to be combined to a 32 bit integer.
I can use <<(8 * i ) but are there any assembly intrinsics to make it quicker?
Note: On C6748 DSP chip and using C compiler v 8.x
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I am receiving UART bytes (8 bit long) and I want every 4 bytes to be combined to a 32 bit integer.
I can use <<(8 * i ) but are there any assembly intrinsics to make it quicker?
Note: On C6748 DSP chip and using C compiler v 8.x
Unfortunately, there are no intrinsics which can help this particular situation.
Thanks and regards,
-George
Suppose you have byte array and that array is aligned on 32 bit boundary. Then you may write to that array with incrementing pointer to char, but read with incrementing pointer to int. This way you'll get LE packed words, like:
... // You did not tell you platform, for C6x every array is at least 4B aligned // Check your environment. char buf[MANY]; char * pc = (char *) &buf[0]; int * pi = ( int *) &buf[0]; *pc++ = ingress_byte; // this way write to buf and move pointer // next after whole buffer reception or after n*4 bytes received // read your 32-bit data as destination = *pi++;