Reading bits in 5-bits chunk in "Memory Aligned" way

Viewed 56

For example, I am trying to read 15 bits from Starting address lets say "11". By definition of memory aligned (15 % 5 == 0). How to read or write these bits in terms (Memory Aligned Access) but the location of bits should also be in such a way that only 1 byte should be read to read a chunk of 5 bits. My thought would be that memory aligned reading should be in the following way.

MSB x  x  x  x  x  x  LSB   : Byte read
 0  0  0  15 14 13 12 11    : 0  
 0  0  0  20 19 18 17 16    : 1
 0  0  0  25 24 23 22 21    : 2
Most-significant three bits are 0-padded in all bytes.

Please share your thoughts and also help me writing a C code to read bits in chunk of 5 bits? Thanks

0 Answers
Related