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
Next revision
Previous revision
playground:reversing_bits_in_a_byte [2020-02-20 21:15] – asl verzplayground:reversing_bits_in_a_byte [2020-03-12 13:05] (current) tlr
Line 51: Line 51:
         asl          asl 
         lda $2         lda $2
-        rol+        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.1582229716.txt.gz · Last modified: 2020-02-20 21:15 by verz