Still new to bitwise operations in 6502 assembly. I would like to have a byte that
has 8 flags. This will store the status of my meta-sprite.
I want to be able to set specific flags without altering the others.
I know how to use ORA to set them to one:
lda status
ora #%00000001 ; set bit 0 to true
sta status
I know how to use EOR to toggle them:
lda status
eor #%00000001 ; if bit 0 = true, then bit 0 = false and vise versa
sta status
Lastly, I know how to check if a bit is true:
lda status
and #%00000001 ; if bit 0 = true then set overflow flag to true
But how to set a specific flag to 0, without altering any others? Even if I used
AND, how would I force it to set the desired bit to 0?
Thanks, I’m sure I’m missing something simple.
How about
Note that all other bits are not touched, since
1 AND Xis alwaysXfor every bit. Only bit 0 changes since0 AND Xis always0.