User Guide

204 64-Bit Media Programming
AMD64 Technology 24592—Rev. 3.15—November 2009
For other 64-bit media instructions, the architecture does not impose data-alignment requirements for
accessing 64-bit media data in memory. Specifically, operands in physical memory do not need to be
stored at addresses that are even multiples of the operand size in bytes. However, the consequence of
storing operands at unaligned locations is that accesses to those operands may require more processor
and bus cycles than for aligned accesses. See “Data Alignment” on page 40 for details.
5.5.5 Integer Data Types
Most of the MMX instructions support operations on the integer data types shown in Figure 5-8 on
page 202. These instructions are summarized in “Instruction Summary—Integer Instructions” on
page 207. The characteristics of these data types are described below.
Sign. Many of the 64-bit media instructions have variants for operating on signed or unsigned
integers. For signed integers, the sign bit is the most-significant bit—bit 7 for a byte, bit 15 for a word,
bit 31 for a doubleword, or bit 63 for a quadword. Arithmetic instructions that are not specifically
named as unsigned perform signed two’s-complement arithmetic.
Maximum and Minimum Representable Values. Table 5-1 shows the range of representable values
for the integer data types.
Saturation. Saturating (also called limiting or clamping) instructions limit the value of a result to the
maximum or minimum value representable by the destination data type. Saturating versions of integer
vector-arithmetic instructions operate on byte-sized and word-sized elements. These instructions—for
example, PADDSx, PADDUSx, PSUBSx, and PSUBUSx—saturate signed or unsigned data
independently for each element in a vector when the element reaches its maximum or minimum
representable value. Saturation avoids overflow or underflow errors.
The examples in Table 5-2 on page 205 illustrate saturating and non-saturating results with word
operands. Saturation for other data-type sizes follows similar rules. Once saturated, the saturated value
is treated like any other value of its type. For example, if 0001h is subtracted from the saturated value,
7FFFh, the result is 7FFEh.
Table 5-1. Range of Values in 64-Bit Media Integer Data Types
Data-Type Interpretation Byte Word Doubleword Quadword
Unsigned
integers
Base-2 (exact) 0 to +2
8
1 0to+2
16
1 0to+2
32
1 0to+2
64
–1
Base-10 (approx.) 0 to 255 0 to 65,535 0 to 4.29 * 10
9
0to1.84*10
19
Signed integers
1
Base-2 (exact) –2
7
to +(2
7
–1)
–2
15
to
+(2
15
–1)
–2
31
to +(2
31
–1) –2
63
to +(2
63
–1)
Base-10 (approx.) –128 to +127
–32,768 to
+32,767
–2.14 * 10
9
to
+2.14 * 10
9
–9.22 * 10
18
to +9.22 * 10
18