pubby wrote:
You have to do 16 bit shifts using ROL, not 8 bit ones, otherwise you throw away bits.
Maybe would help easier if it had said:
You have to do 16-bit shifts using ROL, not 8-bit ones, otherwise you throw away bits.I was confused because I was thinking that pubby was talking about increasing the number of shifts.
But, after seeing that pubby's code uses the exact same number of shifts, ASLs, it made more sense eventually.
pubby wrote:
('addr' is a 2-byte zeropage variable)
Further explaination: 2-byte is 16-bits. Each ASL does shift bit7 into the carry. Each ROL does rotate the carry into bit0. So it is transferring the bits you were throwing away into addr+1 and so pubby's code is correctly using 16-bit bit-shifting.
p.s. Each byte's eight bits are numbered
7 6 5 4 3 2 1 0.