Description:

Some times you must reverse the order of all bits of a byte. E.g. in my Flash programmer the same socket is used for programming AT89C51 and AT89C2051 devices and the data pins of both are at the same location but in reverse order. So I mirror all data from or to the AT89C2051.
There are 3 methods to do it:

1. Use a table with 256 entries, but this is very code expensive (you need 25% of the code space of an AT89C1051). Pay attention, if the program counter used as table location, the table can content only 255 entries (the first index point to the RET after the MOVC instruction, not to the table).

2. Use the RLC A and RRC A instructions for all 8 bits to reverse.
You need 6 times more cycles as the 1. method.

3. Use the advantages of bit manipulation of the 8051 and you get an optimum of needed code and time (I use this method).