True-Color Frame Buffers

 

Endians

Computer memory is traditionally organized in bytes, which are units of 8 consecutive bits. The string "Hello" would typically occupy 6 consecutive byte addresses in memory, represented schematically as follows:

0x00329384 'H'
0x00329385 'e'
0x00329386 'l'
0x00329387 'l'
0x00329388 'o'
0x00329389 '0'

The (hexadecimal) address of each memory location is shown at the left, and the value in that location is shown at the right. Note that the end of the string is indicated by a null character ('0') in some languages, such as C and C++. Other languages may use different conventions.

Suppose, we have a 2-byte integer variable.

In C and C++, this could be indicated by the data type "short" or "unsigned short", or in Java by "short". For definiteness, suppose this integer has the value 12, which is "0x000c" in hexadecimal. If this were stored at the same address as the 'H' in the word "Hello", how would it look?

One possibility would be

0x00329384 '00'
0x00329385 '0c'

This is called "big-endian",

because the most significant byte of the word is stored first (at lower address). Most computer chips use this convention.

The other possibility is, of course,

0x00329384 '0c'
0x00329385 '00'

This is called "little-endian",

for the obvious reason. Intel uses this convention, I suppose just to be different.

Who Cares?

Suppose you read a binary file written on a big-endian computer system using a little-endian system? You will get all the values wrong unless you exchange the order of the bytes. In such a case, you care!