reverse Endianness Algorithm

In computing, endianness is the ordering or sequencing of bytes of a word of digital data in computer memory storage or during transmission. In its narrow sense, endianness refers to the ordering of the bytes (or digits) in an (atomic and contiguous) multi-byte storage object which is conceptually accessed as a whole by appropriate computer hardware instructions. The Intel 8051, contrary to other Intel CPUs, expects 16-bit addresses for LJMP and LCALL in large-endian format; however, xCALL instructions store the return address onto the stack in small-endian format. The DEC Alpha, Atmel AVR, VAX, the MOS technology 6502 family (including Western design center 65802 and 65C816), the Zilog Z80 (including Z180 and eZ80), the Altera Nios II, and many other CPUs and CPU family are also small-endian. The Motorola 6800 / 6801, the 6809 and the 68000 series of CPUs used the large-endian format.

reverse Endianness source code, pseudocode and analysis