2. What is Endianness?
In almost all modern embedded systems, memory is organized into bytes.
CPUs, however, process data as 8-, 16- or 32-bit words. As soon as this word size is larger
than a byte, a decision needs to be made with regard to how the bytes in a word are
stored in memory.
The property that describes this byte ordering is called "endianness" (or, sometimes,
"endianity").
Endian refers to how the order of bytes in a multi-byte value is perceived or acted upon.
Endianness refers to the sequential order in which bytes are arranged into larger
numerical values when stored in memory or when transmitted over digital links.
3. Types of Endianness
Endianness is of interest in computer science because two conflicting and incompatible formats
are in common use i.e. Big Endian and Little Endian.
Words may be represented in big-endian or little-endian format, depending on whether bits or
bytes or other components are ordered from the big end (most significant bit) or the little end
(least significant bit).
In big-endian format, whenever addressing memory or sending/storing words byte wise, the most
significant byte—the byte containing the most significant bit—is stored first (has the lowest
address) or sent first, then the following bytes are stored or sent in decreasing significance order,
with the least significant byte—the one containing the least significant bit—stored last (having
the highest address) or sent last.
Little-endian format reverses this order: the sequence addresses/sends/stores the least significant
byte first (lowest address) and the most significant byte last (highest address).
4. Illustration:- Big Endian and Little
Endian
Consider a 16- bit data from B15 t0 B0 , in which B15 is the most significant bit and B0
is the least significant bit e.g. 2007h
Here 20 i.e. the first 8 bits is the Most Significant byte as it contain the most significant
bit, so you can consider it as Higher order data and the 07 .i.e. the last 8 bits is the least
significant byte as it contain the least significant bit, so it can be considered as the
lower order data.
Now consider the memory addresses as N, N+1, N+2……….in the increasing order, so N
can be consider as the lower address and N+1 as the higher address and so on .
Now if lower address contain the higher order data i.e. the most significant byte and
higher address contain the least significant byte , then it is big endian.
5. Contd.
Reverse of big endian is little endian in which the lower address contain the lower order
data i.e. the least significant byte and higher address contain the higher order data .i.e.
most significant byte.
In big endian address N contain the value 20 and N+1 contain 07 and in little endian N
contain value 07 and N+1 have value 20.
7. Examples
Intel based processors are little endians. ARM processors were little endians. Current
generation ARM processors are bi-endian.
Motorola 68K processors are big endians. PowerPC (by Motorola) and SPARK (by Sun)
processors were big endian. Current version of these processors are bi-endians.
Which one is better — little endian or big endian?
The term little and big endian came from Gulliver’s Travels by Jonathan Swift. Two groups
could not agree by which end an egg should be opened -a-the little or the big. Just like the
egg issue, there is no technological reason to choose one byte ordering convention over the
other, hence the arguments degenerate into bickering about sociopolitical issues. As long as
one of the conventions is selected and adhered to consistently, the choice is arbitrary.