User Tools

Site Tools


playground:reversing_bits_in_a_byte

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
playground:reversing_bits_in_a_byte [2020-02-22 18:40] verzplayground:reversing_bits_in_a_byte [2020-03-12 13:05] (current) tlr
Line 53: Line 53:
         ror         ror
         rts         rts
 +</code>
 +
 +--
 +Optimized version, at 84cycl +rts (enter with the value in .A, result in .A)
 +<code>
 + sta $02 ; 3
 + lda #1 ; 2
 +lp:
 + ror $02 ; 5
 + rol ; 2
 + bcc lp ; 3(2)
 + ; =84
 + rts
 +</code>
 +
 +or slightly unrolled:
 +<code>
 + sta $02 ; 3
 + lda #1 ; 2
 +lp:
 + ror $02 ; 5
 + rol ; 2
 + ror $02 ; 5
 + rol ; 2
 + bcc lp ; 3(2)
 + ; =72
 + rts
 </code> </code>
  
playground/reversing_bits_in_a_byte.txt · Last modified: 2020-03-12 13:05 by tlr