Big Endian / Little Endian

advertisement
Big Endian / Little Endian
When looking at a memory dump, it is important to remember that some architectures reverse the order
of the bytes of an integer number. While it might appear to many that nothing could be simpler than
binary integer numbers, there are at least two different formats for storing twos complement
integers. The difference depends upon the order in which the bytes of an integer are stored in
memory. The Big Endian format stores the most significant bytes (the bytes containing the high order or
left most bits) in the lowest address with the following bytes in sequentially higher addresses. The bytes
would appear in normal order when written from left to right. The Little Endian format stores the least
significant byte (the byte containing the lowest or right most bits) at the lowest address with the
increasingly significant bytes stored at increasing addresses.
For example, consider how the decimal number 258 (0100000010 in binary) would be stored in as a 16
bit binary number.
00000001 00000010
Big Endian
00000010 00000001
Little Endian
When transferring binary integers over a network, it is important to ensure that the sending and
receiving systems use the same format or that a conversion is done. If a Big Endian computer sent the
above binary number to a Little Endian computer without conversion, it would be interpreted as 513.
A 32 bit binary number is stored in a little endian machine with the four bytes in reverse order. The
hexadecimal integer value ABCD1234 will appear in s memory dump of a little endian machine as
34 12 CD AB. Below is a memory display for an Intel Pentium program. Pentiums use a little endian
architecture. The left column of the display shows the memory address in the normal hexadecimal
format (big endian). Location 0X001BF9B4 (circled) contains a memory pointer with the address
0X001BF9CC. The address is stored in reverse byte order, little endian format.
Historical note: The names Big Endian and Little Endian come from Swift’s novel Gulliver’s
Travels. In this story the Lilliputians were divided into the Big Endians and the Little Endians based on
which end of a boiled egg they believed should be opened.
Download