I’m not sure the exact term for what I’m trying to do. I have an 8x8 block of bits stored in 8 bytes, each byte stores one row. When I’m finished, I’d like each byte to store one column.
For example, when I’m finished:
Byte0out = Byte0inBit0 + Bit0inByte1 + Bit0inByte2 + Bit0inByte3 + ...
Byte1out = Bit1inByte0 + Bit1inByte1 + Bit1inByte2 + Bit1inByte3 + ...
What is the easiest way to do this in C which performs well? This will run on a dsPIC microcontroller
This code is cribbed directly from “Hacker’s Delight” – Figure 7-2 Transposing an 8×8-bit matrix, I take no credit for it:
I didn’t check if this rotates in the direction you need, if not you might need to adjust the code.
Also, keep in mind datatypes & sizes –
int&unsigned (int)might not be 32 bits on your platform.BTW, I suspect the book (Hacker’s Delight) is essential for the kind of work you’re doing… check it out, lots of great stuff in there.