8-11
PROGRAMMING WITH THE INTEL MMX TECHNOLOGY
8.3.2.Arithmetic Instructions
The arithmetic instructions perform addition, subtraction, multiplication, and multiply/add oper-
ations on packed data types.
8.3.2.1.PACKED ADDITION AND SUBTRACTION
The PADDSB, PADDSW, and PADDWD (packed add) and PSUBB, PSUBW, and PSUBD
(packed subtract) instructions add or subtract the signed or unsigned data elements of the source
operand to or from the destination operand in wrap- around mode. These instructions support
packed byte, packed word, and packed doubleword data types.
The PADDSB and PADDSW (packed add with saturation) and PSUBSB and PSUBSW (packed
subtract with saturation) instructions add or subtract the signed data elements of the source
operand to or from the signed data elements of the destination operand and saturate the result to
the limits of the signed data-type range. These instructions support packed byte and packed word
data types.
The PADDUSB and PADDUSW (packed add unsigned with saturation) and PSUBUSB and
PSUBUSW (packed subtract unsigned with saturation) instructions add or subtract the unsigned
data elements of the source operand to or from the unsigned data elements of the destination
operand and saturate the result to the limits of the unsigned data-type range. These instructions
support packed byte and packed word data types.
8.3.2.2.PACKED MULTIPLICATION
Packed multiplication instructions perform four multiplications on pairs of signed 16-bit oper-
ands, producing 32-bit intermediate results. Users may choose the low-order or high-order parts
of each 32-bit result.
The PMULHW (packed multiply high) and PMULLW (packed multiply low) instructions
multiply the signed words of the source and destination operands and write the high-order or
low-order 16 bits of each of the results to the destination operand.
8.3.2.3.PACKED MULTIPLY ADD
The PMADDWD (packed multiply and add) instruction calculates the products of the signed
words of the source and destination operands. The four intermediate 32-bit doubleword products
are summed in pairs to produce two 32-bit doubleword results.
8.3.3.Comparison Instructions
The PCMPEQB, PCMPEQW, and PCMPEQD (packed compare for equal) and PCMPGTB,
PCMPGTW, and PCMPGTD (packed compare for greater than) instructions compare the corre-
sponding data elements in the source and destination operands for equality or value greater than,
respectively. These instructions generate a mask of ones or zeros which are written to the desti-
nation operand. Logical operations can use the mask to select elements. This can be used to