AMCC Proprietary 44
Revision 1.02 - September 10, 2007
PPC405 Processor
Preliminary User’s Manual
2.5 Byte Ordering
The following discussion describes the “endianness” of the PPC405 core, which, by default and in normal use is
“big endian.” The PPC405 also contains “little endian” peripherals and supports the attachment of external little
endian peripherals.
If scalars (individual data items and instructions) were indivisible, there would be no such concept as “byte
ordering.” It is meaningless to consider the order of bits or groups of bits within the smallest addressable unit of
storage because nothing can be observed about such order. Only when scalars, which the programmer and
processor regard as indivisible quantities, can comprise more than one addressable unit of storage does the
question of byte order arise.
For a machine in which the smallest addressable unit of storage is the 32-bit word, there is no question of the
ordering of bytes within words. All transfers of individual scalars between registers and storage are of words, and
the address of the byte containing the high-order eight bits of a scalar is no different from the address of a byte
containing any other part of the scalar.
For the PowerPC Architecture, as for most computer architectures currently implemented, the smallest
addressable unit of storage is the 8-bit byte. Other scalars are halfwords, words, or doublewords, which consist of
groups of bytes. When a word-length scalar is moved from a register to storage, the scalar is stored in four
consecutive byte addresses. It thus becomes meaningful to discuss the order of the byte addresses with respect to
the value of the scalar: that is, which byte contains the highest-order eight bits of the scalar, which byte contains
the next-highest-order eight bits, and so on.
Given a scalar that contains multiple bytes, the choice of byte ordering is essentially arbitrary. There are 4! = 24
ways to specify the ordering of four bytes within a word, but only two of these orderings are sensible:
• The ordering that assigns the lowest address to the highest-order (“leftmost”) eight bits of the scalar, the next
sequential address to the next-highest-order eight bits, and so on.
This ordering is called big endian because the “big end” (most significant end) of the scalar, considered as a
binary number, comes first in storage.
• The ordering that assigns the lowest address to the lowest-order (“rightmost”) eight bits of the scalar, the next
sequential address to the next-lowest-order eight bits, and so on.
This ordering is called little endian because the “little end” (least significant end) of the scalar, considered as a
binary number, comes first in storage.
2.5.1 Structure Mapping Examples
The following C language structure, s, contains an assortment of scalars and a character string. The comments
show the value assumed to be in each structure element; these values show how the bytes comprising each
structure element are mapped into storage.
struct {
int a; /* 0x1112_1314 word */
long long b; /* 0x2122_2324_2526_2728 doubleword */
char *c; /* 0x3132_3334 word */
char d[7]; /* 'A','B','C','D','E','F','G' array of bytes */
short e; /* 0x5152 halfword */
int f; /* 0x6162_6364 word */
} s;