So you want to say, I can shift left or right whole contents of an array?
So you want to say, I can shift left or right whole contents of an array?
Are you using the shiftout command? If so you can select MSB or LSB first.
No, there is no "one command way" to shift or rotate bits spanning multiple members of an an array. You will have to write some code to do that.
Start with the least significant byte, use the Shift-Left "<<", then check the STATUS Register Carry bit to see if you have to add one to the more significant byte after shifting.
I'm thinking it in the following way (as example, 2 byte array, shifted to right)
1. Read both array bytes into variables A and B
2. Shift B right 1 bit
3. Add LSB from A as MSB to B
4. Shift A right
5. Write A and B back to array
Repeat as desired.
Correct?
Yes, assuming you really do want a shift and don't want to rotate the value shifted out of B back into the MSB of the array.
There's no need to copy the array bytes to A and B, but if it helps you keep it straight then go for it.
Bookmarks