
RCPU
REFERENCE MANUAL
OPERAND CONVENTIONS
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
3-3
If individual data items were indivisible, the concept of byte ordering would be un-
necessary. The order of bits or groups of bits within the smallest addressable unit
of memory is irrelevant, because nothing can be observed about such order. Order
matters only when scalars, which the processor and programmer regard as indivis-
ible quantities, can be made up of more than one addressable units of memory.
For a device in which the smallest addressable unit is the 64-bit double word, there
is no question of the order of bytes within double words. All transfers of individual
scalars between registers and system memory are of double words. A subset of
the 64-bit scalar (for example, a byte) is not addressable in memory. As a result, to
access any subset of the bits of a scalar, the entire 64-bit scalar must be accessed,
and when a memory location is read, the 64-bit value returned is the 64-bit value
last written to that location.
For PowerPC processors, the smallest addressable memory unit is the byte (8
bits), and scalars are composed of one or more sequential bytes. When a 32-bit
scalar is moved from a register to memory, it occupies four consecutive byte ad-
dresses, and a decision must be made regarding the order of these bytes in these
four addresses.
3.2.1 Structure Mapping Examples
The following C programming example contains an assortment of scalars and one
character string. The value presumed to be in each structure element is shown in
hexadecimal in the comments and are used below to show how the bytes that com-
prise each structure element are mapped into memory.
struct {
int
double
char *
char
short
int
a;
b;
c;
d[7];
e;
f;
/* 0x1112_1314
/* 0x2122_2324_2526_2728
/* 0x3132_3334
/* ‘A’,‘B’,‘C’,‘D’,‘E’,‘F’,‘G’array of bytes */
/* 0x5152
/* 0x6162_6364
word
doubleword
word
*/
*/
*/
halfword
word
*/
*/
} s;
Note that the C structure mapping introduces padding (skipped bytes) in the map
in order to align the scalars on their proper boundaries — four bytes between
a
and
b
, one byte between
d
and
e
, and two bytes between
e
and
f
. Both big- and little-
endian mappings use the same amount of padding.
3.2.1.1 Big-Endian Mapping
The big-endian mapping of a structure
S
is shown in
Figure 3-2
. Addresses are
shown in hexadecimal at the left of each double word and in small figures below
each byte. The content of each byte, as shown in the preceding C programming
example, is shown in hexadecimal as characters for the elements of the string.
F
Freescale Semiconductor, Inc.
n
.