AMD amd64 architecture User Manual

Page of 336
216
64-Bit Media Programming
AMD64 Technology
24592—Rev. 3.15—November 2009
5.6.6 Arithmetic
The integer vector-arithmetic instructions perform an arithmetic operation on the elements of two
source vectors. Arithmetic instructions that are not specifically named as unsigned perform signed
two’s-complement arithmetic.
Addition
PADDB—Packed Add Bytes
PADDW—Packed Add Words
PADDD—Packed Add Doublewords
PADDQ—Packed Add Quadwords
PADDSB—Packed Add with Saturation Bytes
PADDSW—Packed Add with Saturation Words
PADDUSB—Packed Add Unsigned with Saturation Bytes
PADDUSW—Packed Add Unsigned with Saturation Words
The PADDB, PADDW, PADDD, and PADDQ instructions add each 8-bit (PADDB), 16-bit (PADDW),
32-bit (PADDD), or 64-bit (PADDQ) integer element in the second operand to the corresponding,
same-sized integer element in the first operand. The instructions then write the integer result of each
addition to the corresponding, same-sized element of the destination. These instructions operate on
both signed and unsigned integers. However, if the result overflows, only the low-order byte, word,
doubleword, or quadword of each result is written to the destination. The PADDD instruction can be
used together with PMADDWD (page 218) to implement dot products.
The PADDSB and PADDSW instructions perform additions analogous to the PADDB and PADDW
instructions, except with saturation. For each result in the destination, if the result is larger than the
largest, or smaller than the smallest, representable 8-bit (PADDSB) or 16-bit (PADDSW) signed
integer, the result is saturated to the largest or smallest representable value, respectively.
The PADDUSB and PADDUSW instructions perform saturating additions analogous to the PADDSB
and PADDSW instructions, except on unsigned integer elements.
Subtraction
PSUBB—Packed Subtract Bytes
PSUBW—Packed Subtract Words
PSUBD—Packed Subtract Doublewords
PSUBQ—Packed Subtract Quadword
PSUBSB—Packed Subtract with Saturation Bytes
PSUBSW—Packed Subtract with Saturation Words
PSUBUSB—Packed Subtract Unsigned and Saturate Bytes
PSUBUSW—Packed Subtract Unsigned and Saturate Words