There are two approaches to endian mapping: address invariance and data invariance.
Address Invariance
In this type of mapping, the byte address is always kept between large and small. This has a side effect of changing the order of significance (the most significant to the least significant) of a particular binding (for example, 2 or 4 byte words) and, therefore, the interpretation of the data. In particular, in little-endian the interpretation of data is the least significant for most significant bytes, while in big-endian the interpretation is most significant for the least significant. In both cases, the set of available bytes remains unchanged.
Example
Address Invariance (also known as Byte Invariance): The byte address is constant, and the byte value is canceled.
Addr Memory 7 0 | | (LE) (BE) |----| +0 | aa | lsb msb |----| +1 | bb | : : |----| +2 | cc | : : |----| +3 | dd | msb lsb |----| | | At Addr=0: Little-endian Big-endian Read 1 byte: 0xaa 0xaa (preserved) Read 2 bytes: 0xbbaa 0xaabb Read 4 bytes: 0xddccbbaa 0xaabbccdd
Data invariance
In this type of mapping, the relative byte value is stored for data of a certain size. Therefore, there are different types of finite mappings that are invariant with respect to the data for different sizes. For example, a 32-bit word-invariant final matching will be used for database size 32. The effect of storing a binding value of a certain size is that byte addresses of bytes within the basis are between large and small suffixes.
Example
32-bit data invariance (also known as word invariance): A basis is a 32-bit word that always has a value of 0xddccbbaa , independent of conformation. However, for access smaller than words, the byte address is reversed between large and small endian mappings.
Addr Memory | +3 +2 +1 +0 | <- LE |-------------------| +0 msb | dd | cc | bb | aa | lsb |-------------------| +4 msb | 99 | 88 | 77 | 66 | lsb |-------------------| BE -> | +0 +1 +2 +3 | At Addr=0: Little-endian Big-endian Read 1 byte: 0xaa 0xdd Read 2 bytes: 0xbbaa 0xddcc Read 4 bytes: 0xddccbbaa 0xddccbbaa (preserved) Read 8 bytes: 0x99887766ddccbbaa 0x99887766ddccbbaa (preserved)
Example
16-bit data invariance (also known as half-word invariance): the null element is a 16-bit one that always has a value of 0xbbaa , independent of conformation. However, for access less than a half-word, the byte address is reversed between large and small endian mappings.
Addr Memory | +1 +0 | <- LE |---------| +0 msb | bb | aa | lsb |---------| +2 msb | dd | cc | lsb |---------| +4 msb | 77 | 66 | lsb |---------| +6 msb | 99 | 88 | lsb |---------| BE -> | +0 +1 | At Addr=0: Little-endian Big-endian Read 1 byte: 0xaa 0xbb Read 2 bytes: 0xbbaa 0xbbaa (preserved) Read 4 bytes: 0xddccbbaa 0xddccbbaa (preserved) Read 8 bytes: 0x99887766ddccbbaa 0x99887766ddccbbaa (preserved)
Example
64-bit data invariance (also known as double invariance): A basis is a 64-bit word that always has a value of 0x99887766ddccbbaa that is independent of the entity. However, for access smaller than a double word, the byte address is reversed between large and small endian mappings.
Addr Memory | +7 +6 +5 +4 +3 +2 +1 +0 | <- LE |---------------------------------------| +0 msb | 99 | 88 | 77 | 66 | dd | cc | bb | aa | lsb |---------------------------------------| BE -> | +0 +1 +2 +3 +4 +5 +6 +7 | At Addr=0: Little-endian Big-endian Read 1 byte: 0xaa 0x99 Read 2 bytes: 0xbbaa 0x9988 Read 4 bytes: 0xddccbbaa 0x99887766 Read 8 bytes: 0x99887766ddccbbaa 0x99887766ddccbbaa (preserved)