For example, a 16 bit compare:
Code: Select all
foo .res 2 ; 16 bit variables
bar .res 2
lda foo
cmp bar ; carry clear if low byte of foo < bar, set if foo >= bar
lda foo + 1
sbc bar + 1 ; subtract high byte bar, or in effect subtract one more if foo < bar
bcc label ; if all 16 bits foo < bar goto label
The cmp instruction always sets the carry first, so for the second part of the compare you have to use sbc to not set the carry.