Sunday, June 2, 2013


Screen Shot 2013 06 02 at 4 50 21 PM

When programming on Intel CPU, I wondered why the debugger showed the integer values reverse order. The AX register has the value 0x04030201, but when I store the value in memory at 0x1000, the value I see at 0x1000 is 01020304.

That's because Intel uses little endian for their CPU architecture. Little endian stores LSB byte (little byte) first whereas big endian stores MSB first. So the stored value will be 04030201. It's also because we write numbers from left to right. If we have the culture to write from right to left, the little endianness looks OK as we would write 010203040x.

The Internet Protocol defines big-endian as the standard network byte order. When streaming multiple byte data, the first arrived byte is the MSB.