Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Zero page free bytes
- ZPFB = $FB
- ZPFC = $FC
- *=$0801
- BYTE $0E, $08, $0A, $00, $9E, $20, $28, $32, $30, $36, $34, $29, $00, $00, $00
- ; Test
- lda #%11111110 ; Value
- ldx #1 ; Source bit 1
- ldy #0 ; Target bit 0
- jsr CopyBitXOnY ; Call Generic copy bit routine
- sta $0400 ; print raw result code 255
- rts
- Mask
- byte %11111110 ; 0
- byte %11111101 ; 1
- byte %11111011 ; 2
- byte %11110111 ; 3
- byte %11101111 ; 4
- byte %11011111 ; 5
- byte %10111111 ; 6
- byte %01111111 ; 7
- ;******************************************************************************
- ; CopyBitXOnY
- ; A = Value
- ; X = Source bit
- ; Y = Target bit
- ; return
- ; A with Target bit equal to Source Bit
- ;******************************************************************************
- CopyBitXOnY
- sta ZPFB ; Save value
- lda Mask,y ; load target reset Mask
- and ZPFB ; reset target bit
- sta ZPFB ; save Value
- lda Mask,x ; Load source reset Mask
- eor #$ff ; change it on source set mask
- and ZPFB ; test source bit
- beq CB_Exit ; if zero then exit
- lda Mask,y ; load target reset Mask
- eor #$ff ; change it on target set mask
- ora ZPFB ; set target bit
- rts
- CB_Exit
- lda ZPFB ; load value
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement