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.
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