Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; val: zeropage location for the value
- ; y: source bit
- ; x: destination bit
- lda val ; could be "sta val" if value is already in .A
- and setbit,y
- beq zeroit
- setit:
- lda val
- ora setbit,x
- rts
- zeroit:
- lda val
- and voidbit,x
- rts
- setbit:
- byte 1,2,4,8,16,32,64,128 ; values with only one bit set
- voidbit:
- byte 254,253,251,247,239,223,191,127 ; values with only one bit clear
- ; Shorter version, just one table
- lda setbit,y
- and val
- beq zeroit
- setit:
- lda setbit,x
- ora val
- rts
- zeroit:
- lda setbit,x
- eor #$ff
- and val
- rts
- setbit:
- byte 1,2,4,8,16,32,64,128 ; values with only one bit set
Add Comment
Please, Sign In to add comment