5-2
DATA TYPES AND ADDRESSING MODES
Figure 5-2 shows the byte order of each of the fundamental data types when referenced as oper-
ands in memory. The low byte (bits 0 through 7) of each data type occupies the lowest address
in memory and that address is also the address of the operand.
5.1.1.Alignment of Words, Doublewords, and Quadwords
Words, doublewords, and quadwords do not need to be aligned in memory on natural bound-
aries. (The natural boundaries for words, double words, and quadwords are even-numbered
addresses, addresses evenly divisible by four, and addresses evenly divisible by eight, respec-
tively.) However, to improve the performance of programs, data structures (especially stacks)
should be aligned on natural boundaries whenever possible. The reason for this is that the
processor requires two memory accesses to make an unaligned memory access; whereas,
aligned accesses require only one memory access. A word or doubleword operand that crosses
a 4-byte boundary or a quadword operand that crosses an 8-byte boundary is considered
unaligned and requires two separate memory bus cycles to access it; a word that starts on an odd
address but does not cross a word boundary is considered aligned and can still be accessed in
one bus cycle.
When accessing 128 bit data for the Pentium
®
III processor, data must be aligned on 16-byte
boundaries. There are instructions that allow for unaligned access, but additional time is
required to receive the data into the cache. If an instruction that expects aligned data is used to
access unaligned data, a general protection fault will occur.
Figure 5-3. Bytes, Words, Doublewords and Quadwords in Memory
EH
DH
7AH
CH
FEH
BH
06H
AH
36H
9H
1FH
8H
A4H
7H
23H
6H
0BH
5H
4H
3H
74H
2H
CBH
1H
31H
0H
Quadword at Address 6H
Contains 7AFE06361FA4230BH
Doubleword at Address AH
Contains 7AFE0636H
Word at Address BH
Contains FE06H
Byte at Address 9H
Contains 1FH
Word at Address 6H
Contains 230BH
Word at Address 1H
Contains CB31H
Word at Address 2H
Contains 74CBH