July 2002
Intermediate to advanced
320 pages
8h 15m
English
By “reversing bits” we mean to reflect the contents of a register about the middle so that, for example,
![]()
By “reversing bytes” we mean a similar reflection of the four bytes of a register. Byte reversal is a necessary operation to convert data between the “little-endian” format used by DEC and Intel and the “big-endian” format used by most other manufacturers.
Bit reversal can be done quite efficiently by interchanging adjacent single bits, then interchanging adjacent 2-bit fields, and so on, as shown below [Aus1]. These five assignment statements can be executed in any order.
x = (x & 0x55555555) << 1 | (x & 0xAAAAAAAA) ...
Read now
Unlock full access