playground:reversing_bits_in_a_byte
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
playground:reversing_bits_in_a_byte [2020-02-20 21:15] – asl verz | playground:reversing_bits_in_a_byte [2020-03-12 13:05] (current) – tlr | ||
---|---|---|---|
Line 51: | Line 51: | ||
asl | asl | ||
lda $2 | lda $2 | ||
- | | + | |
rts | rts | ||
+ | </ | ||
+ | |||
+ | -- | ||
+ | Optimized version, at 84cycl +rts (enter with the value in .A, result in .A) | ||
+ | < | ||
+ | sta $02 ; 3 | ||
+ | lda #1 ; 2 | ||
+ | lp: | ||
+ | ror $02 ; 5 | ||
+ | rol ; 2 | ||
+ | bcc lp ; 3(2) | ||
+ | ; =84 | ||
+ | rts | ||
+ | </ | ||
+ | |||
+ | or slightly unrolled: | ||
+ | < | ||
+ | sta $02 ; 3 | ||
+ | lda #1 ; 2 | ||
+ | lp: | ||
+ | ror $02 ; 5 | ||
+ | rol ; 2 | ||
+ | ror $02 ; 5 | ||
+ | rol ; 2 | ||
+ | bcc lp ; 3(2) | ||
+ | ; =72 | ||
+ | rts | ||
</ | </ | ||
playground/reversing_bits_in_a_byte.1582229716.txt.gz · Last modified: 2020-02-20 21:15 by verz