Endianness
Endianness refers to the order in which bytes are placed to main memory.
Little endian
In little endian the least significant byte is stored at the lowest address (base address), and the other bytes are stored in higher addresses in order of significance. Let's say we have an eax register with value 0xCAFEF00D and we want to move it to address 0x00001000. The result will be
Address | Value |
---|---|
0x00001000 | 0x0D |
0x00001001 | 0xF0 |
0x00001002 | 0xFE |
0x00001003 | 0xCA |
This may seem unlogical until you consider that a variable can be used more easily as both 8-bit, 16-bit, 32-bit or even 64-bit without changing its base address.
Big endian
On the other side, in big endian the most significant byte is stored at the lowest address (base address), and the other bytes are stored in higher addresses in inverse order of significance. That's more human readable as it resembles left-to-right order of digits. Let's say we have an eax register with value 0xCAFEF00D and we want to move it to address 0x00001000. The result will be
Address | Value |
---|---|
0x00001000 | 0xCA |
0x00001001 | 0xFE |
0x00001002 | 0xF0 |
0x00001003 | 0x0D |
Example CPUs
CPU | Endian |
---|---|
x86 | Little |
x86-64 | Little |
Motorola | Big |
68k | Big |
PowerPC | Both |