Prev: 39504 Up: Map Next: 39581
39570: Reverse Bits
Used by the routines at DrawGraphic_Mirrored and DrawGraphic_RotatedHalf.
Reverses the order of the bits in a byte.
Input
A The byte
Output
A The byte with its bits reversed
ReverseBits 39570 PUSH BC Stash BC on the stack.
39571 LD B,8 B=8 (the number of bits to reverse).
ReverseBits_Loop 39573 RLA Rotate the top bit of A into the carry flag.
39574 RR C Rotate the carry flag into the top of C.
39576 DJNZ ReverseBits_Loop Decrease the bit counter by one and loop back to ReverseBits_Loop until all eight bits have been reversed.
39578 LD A,C Fetch the reversed byte.
39579 POP BC Restore BC from the stack.
39580 RET Return.
Prev: 39504 Up: Map Next: 39581