Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; 6502 parity calculation by Damian Yerrick
- ; licensed under creative commons zero
- .proc parity_by_adding
- bytetosend = 0
- lda bytetosend
- lsr a
- eor bytetosend
- ; diverge starts here
- and #%01010101 ; ,6.4.2.0
- ; Possible nibbles: 0, 1, 4, or 5.
- ; If we add 3, we get 3, 4, 7, or 8, whose bit 2
- ; is the nibble's parity.
- clc
- adc #%00110011 ; combine 0 into 2 and 4 into 6
- and #%01000100 ; .6...2..
- ; now possible bytes are $00, $04, $40, or $44
- adc #%00111100 ; combine bit 2 into bit 6
- and #%01000000
- ; At this point, bit 6 is parity and bit 7 is 1.
- ; Therefore we can AND #%01000000 if we want to BNE,
- ; ASL A if we want to BMI, or if we want to BCS:
- cmp #1
- ; 18 bytes 22 cycles so far
- rts
- .endproc
- ; 6502 parity calculation by Kevin Horton
- ; from http://pastebin.com/eRibRP6G
- .proc parity_by_shifting
- bytetosend = 0
- lda bytetosend
- lsr a
- eor bytetosend
- sta bytetosend
- lsr a
- lsr a
- eor bytetosend
- sta bytetosend
- lsr a
- lsr a
- lsr a
- lsr a
- eor bytetosend
- lsr a
- ; 20 bytes 34 cycles so far
- rts
- .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement