here is a simple predicament that seems to have me temporarily baffled due to a lack of sleep. My program was acting up & I found a simple branch might be the problem.
say temp=r18 contains 33 hex. I want to add 20 hex to this value & and branch whenever volts=r19 is less than this sum:
ldi temp, data ;get the value
subi temp, $E0 ; "ADD" 20
cp volts, temp
brlo do_it ;volts<= temp+20
This seems to work, but if temp is, say $F3, then adding $20 gives $13. Then a value such as $F5 will not be "lower" than the sum as intended. Essentially the rollover will screw everything up. I can program a workaround with a lot of tests & manipulations--but is there a simple wayto avoid these types of rollover problems?