The following code doesn't work...
Code: Select all
dim shiftreg as longword
dim shift as byte
for shift = 1 to 31
shiftreg = $80005A5A // test pattern
shiftreg = shiftreg >> shift // this line doesn't work correctly
next
It does an optimization where it places (or tries to) 'shift' into the WREG, and then does a little loop to do the shift, decrementing WREG as the loop count. The problem is it screws up the initial loading of WREG. This doesn't seem to happen if 'shiftreg' is declared as a byte or a word, or for doing left shifts (as it uses a different algorithm).
A fix/kludge around this would be
Code: Select all
for shift = 1 to 31
shiftreg = $80005A5A
WREG = shift
shiftreg = shiftreg >> WREG
next
Jerry