#1,083 – Using Visual Studio to Verify Little-Endianness

We know that Intel processors use a “little-endian” scheme when deciding how to store binary data in memory.  That is, bytes from the “little end” of a number will be stored earlier in memory than the bytes from the “big end”.

We can see this little-endianness in action by using Visual Studio to look at how a data item is stored in memory.

Let’s say that we have a 4-byte (32-bit) unsigned integer with a value of 0x1234ABCD, assigned to a variable named “myNumber”.  We can view the memory location where this number is stored by bringing up the Memory window in Visual Studio and then entering “&myNumber” in the Address area.

1083-001

1083-002

When you press RETURN, you’ll see the memory location where myNumber is stored.  Notice that the first byte is CD, followed by AB, etc.  The number is stored in a little-endian manner.

1083-003

 

#1,082 – Big-endian and Little-endian

The terms “big-endian” and “little-endian” refer to the scheme that a computer uses to store binary data in memory.  The basic difference is:

  • Big-endian (e.g. IBM mainframes, Motorola 68000) – leftmost byte is stored first, followed by other bytes, left-right.  (“Big end” of number stored first)
  • Little-endian (e.g. Intel processors) – rightmost byte is stored first, followed by other bytes, right-left.  (“Little end” of number stored first)

Below is an example.  Assume that have a 4-byte (32-bit) number with a value of 0x1234ABCD (hex).  The diagram below shows how this number would be stored in a 4-byte chunk of memory, based on whether the processor uses the big-endian or the little-endian convention.

1082-001