For years I’ve been using the following simple code to reverse the bits in the A register by rotating the bits left out of one register and right into another:
; reverse bits in A
; 8 bytes / 206 cycles
ld b,8
ld l,a
REVLOOP:
rl l
rra
djnz REVLOOP
Recently I wondered if it’s possible to save a few cycles.
thank to JM @ http://www.retroprogramming.com/