arrays - Serialize / transpose data in C (PIC 32) -
what efficient (fastest) way serialize / transpose info in odd way. let's have 8 array info in them.
char array0[10]; char array1[10]; ............. char array7[10]; need output array have: output[80]; output.byte0.bit0 = array0.byte0.bit0 output.byte0.bit1 = array1.byte0.bit0 output.byte0.bit2 = array2.byte0.bit0 output.byte0.bit3 = array3.byte0.bit0 ..................................... output.byte0.bit7 = array7.byte0.bit0 output.byte1.bit0 = array0.byte0.bit1 output.byte1.bit1 = array1.byte0.bit1 output.byte1.bit2 = array2.byte0.bit1 output.byte1.bit3 = array3.byte0.bit1 ..................................... output.byte1.bit7 = array7.byte0.bit1
basically bit0 of output array contains serialized info of input array0. bit1 of output array contains serialized info of input array1 etc...
i'm using microchip pic32 device shouldn't matter much, still standard c
i don't see why need such thing can using shift operator.
you need create matrix arrays:
char array[n][m]
and this:
int i=0; ( int e = 0 ; e < m ; e++ ) //~ e element number (int m = 0 ; m < 8 ; m++ ) //~ m mask { char aux=0; (int = 0 ; < n ; a++ ) //~ array { char temp = array[a][e] & (0x01 << m ); temp >>= m; temp <<= a; aux |= temp; } output[i++]= aux; }
n should 8, , 8 only.
c arrays pic pic32
No comments:
Post a Comment