[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
LittleEndian
Intel, while designing the 8088/8086 series of microprocessors, decided to use the "Little endian" format for storing multi-byte values rather instead of the "Big Endian" format that other processors used.
First, let's discuss the big endian format. This is the way that we would expect numbers to be stored in memory. If we have a binary number (word) "01010101 00000010 b" = "55 02h", it would be stored in the memory at say 00724h in the following way:
But, in the case of "Little endian" format the same word would be stored in the memory as:
With little endian format, we order the bytes in reverse. The bits in each byte stay in the same order, but the bytes themselves are stored in a backwards order. Notice that the storage location at the lower address, 00724h contains the value 00000010b = 02h. Moreover, the contents of the next higher addressed storage location 00725h are 01010101b = 55h. These two bytes represent the word 0101010100000010b = 5502h.
A double word corresponds to four consecutive bytes of data stored in memory. The value "A0 00 55 FF h" will be stored as:
The reason that is commonly given for the little-endian format is that this format makes it easier to add to or increment a multi-byte number: if there is an overflow, you just increment the address (by one byte), and then add one to the byte at that address.
Motorola's 68000 processor family (used in Macs, Amigas, and other machines) is probably the most famous example of a processor family that uses the big-endian format.
References:
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
LittleEndian
Intel, while designing the 8088/8086 series of microprocessors, decided to use the "Little endian" format for storing multi-byte values rather instead of the "Big Endian" format that other processors used.
First, let's discuss the big endian format. This is the way that we would expect numbers to be stored in memory. If we have a binary number (word) "01010101 00000010 b" = "55 02h", it would be stored in the memory at say 00724h in the following way:
|Address|--------|Memory---|------|Memory|
|-------|--------|(binary)-|------|(hex)-|
|00724h-|--------|0101 0101|------|5 5---|
|00725h-|--------|0000 0010|------|0 2---|
But, in the case of "Little endian" format the same word would be stored in the memory as:
|Address|--------|Memory---|------|Memory|
|-------|--------|(binary)-|------|(hex)-|
|00725h-|--------|0101 0101|------|5 5---|
|00724h-|--------|0000 0010|------|0 2---|
With little endian format, we order the bytes in reverse. The bits in each byte stay in the same order, but the bytes themselves are stored in a backwards order. Notice that the storage location at the lower address, 00724h contains the value 00000010b = 02h. Moreover, the contents of the next higher addressed storage location 00725h are 01010101b = 55h. These two bytes represent the word 0101010100000010b = 5502h.
A double word corresponds to four consecutive bytes of data stored in memory. The value "A0 00 55 FF h" will be stored as:
--------------------------
|Address| -> |Memory(Hex)|
--------------------------
|0000Bh-| -> |A0---------|
|0000Ah-| -> |00---------|
|00009h-| -> |55---------|
|00008h-| -> |FF---------|
--------------------------
The reason that is commonly given for the little-endian format is that this format makes it easier to add to or increment a multi-byte number: if there is an overflow, you just increment the address (by one byte), and then add one to the byte at that address.
Motorola's 68000 processor family (used in Macs, Amigas, and other machines) is probably the most famous example of a processor family that uses the big-endian format.
References:
- www.atrevida.com - Atrevida Game Programming Tutorials
- Assembly Language for the PC, 3rd ed., John Socha and Peter Norton, Prentice Hall of India Pvt. Ltd. 1996
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
