Intel 64 and IA-32 Architectures Software Developers Manual Volume 2B, Instruction Set Reference, N-Z

Vol. 2B 4-79
INSTRUCTION SET REFERENCE, N-Z
PHSUBW/PHSUBD — Packed Horizontal Subtract
Description
PHSUBW performs horizontal subtraction on each adjacent pair of 16-bit signed inte-
gers by subtracting the most significant word from the least significant word of each
pair in the source and destination operands, and packs the signed 16-bit results to
the destination operand (first operand). PHSUBD performs horizontal subtraction on
each adjacent pair of 32-bit signed integers by subtracting the most significant
doubleword from the least significant doubleword of each pair, and packs the signed
32-bit result to the destination operand. Both operands can be MMX or XMM regis-
ters. When the source operand is a 128-bit memory operand, the operand must be
aligned on a 16-byte boundary or a general-protection exception (#GP) will be
generated.
In 64-bit mode, use the REX prefix to access additional registers.
Operation
PHSUBW with 64-bit operands:
mm1[15-0] = mm1[15-0] - mm1[31-16];
mm1[31-16] = mm1[47-32] - mm1[63-48];
mm1[47-32] = mm2/m64[15-0] - mm2/m64[31-16];
mm1[63-48] = mm2/m64[47-32] - mm2/m64[63-48];
PHSUBW with 128-bit operands:
xmm1[15-0] = xmm1[15-0] - xmm1[31-16];
xmm1[31-16] = xmm1[47-32] - xmm1[63-48];
xmm1[47-32] = xmm1[79-64] - xmm1[95-80];
xmm1[63-48] = xmm1[111-96] - xmm1[127-112];
Opcode Instruction
64-Bit
Mode
Compat/
Leg Mode Description
0F 38 05 /r PHSUBW mm1,
mm2/m64
Valid Valid Subtract 16-bit signed
integers horizontally,
pack to MM1.
66 0F 38 05 /r PHSUBW
xmm1,
xmm2/m128
Valid Valid Subtract 16-bit signed
integers horizontally,
pack to XMM1.
0F 38 06 /r PHSUBD mm1,
mm2/m64
Valid Valid Subtract 32-bit signed
integers horizontally,
pack to MM1.
66 0F 38 06 /r PHSUBD xmm1,
xmm2/m128
Valid Valid Subtract 32-bit signed
integers horizontally,
pack to XMM1.