halkun wrote:
Also, How would I effectively use BIT to do this?
BIT effectively performs an AND, to retain bits you're interested in, and ignore the rest via masking them off. It would be appropriate to use when checking for %xxxxxxx0 and %xxxxxxx1 (lda #1, bit $ea, bne/beq), but not specifically for %00000000 or %00000001 if 2-255 are also possible values.
From reading your original post, what you describe is basically a state machine, so I can't help but see it as 2 different comparisons:
Code:
; First part, check if it's 1
ldx $ea ; using .X for byte-brevity of dex, vs .A and cmp
dex
bne skip
; Second part, conditionally wait until it's zero
loop:
ldx $ea
bne loop
skip:
Maybe it could be code golfed down into 1, using bit shifting like
Code:
lda $ea
lsr
bne case2_255
bcc case0
bcs case1
but the way you word it, there is a stateful decision whether or not to perform the waiting for 0, based on a previous read.