Here's a clever way to do it that I found via Google: // // Reverse the order of bits within a byte. // Returns: The reversed byte value. // BYTE ReverseBits(BYTE b) { BYTE c; c = ((b >> 1) & 0x55) | ((b << 1) & 0xaa); c |= ((b >> 2) & 0x33) | ((b << 2) & 0xcc); c |= ((b >> 4) & 0x0f) | ((b << 4) & 0xf0); return(c); }
I haven't checked it, though. Leon Heller, G1HSM Email: aqz...@dsl.pipex.com My low-cost Philips LPC210x ARM development system: http://www.geocities.com/leon_heller/lpc2104.html