Intel 64 and IA-32 Architectures Software Developers Manual Volume 2B, Instruction Set Reference, N-Z
4-82 Vol. 2B
INSTRUCTION SET REFERENCE, N-Z
PHSUBSW — Packed Horizontal Subtract and Saturate
Description
PHSUBSW performs horizontal subtraction on each adjacent pair of 16-bit signed
integers by subtracting the most significant word from the least significant word of
each pair in the source and destination operands. The signed, saturated 16-bit
results are packed to the destination operand (first operand). Both operands can be
MMX or XMM register. 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
PHSUBSW with 64-bit operands:
mm1[15-0] = SaturateToSignedWord(mm1[15-0] - mm1[31-16]);
mm1[31-16] = SaturateToSignedWord(mm1[47-32] - mm1[63-48]);
mm1[47-32] = SaturateToSignedWord(mm2/m64[15-0] - mm2/m64[31-16]);
mm1[63-48] = SaturateToSignedWord(mm2/m64[47-32] - mm2/m64[63-48]);
PHSUBSW with 128-bit operands:
xmm1[15-0] = SaturateToSignedWord(xmm1[15-0] - xmm1[31-16]);
xmm1[31-16] = SaturateToSignedWord(xmm1[47-32] - xmm1[63-48]);
xmm1[47-32] = SaturateToSignedWord(xmm1[79-64] - xmm1[95-80]);
xmm1[63-48] = SaturateToSignedWord(xmm1[111-96] - xmm1[127-112]);
xmm1[79-64] = SaturateToSignedWord(xmm2/m128[15-0] - xmm2/m128[31-16]);
xmm1[95-80] =SaturateToSignedWord(xmm2/m128[47-32] - xmm2/m128[63-48]);
xmm1[111-96] =SaturateToSignedWord(xmm2/m128[79-64] - xmm2/m128[95-80]);
xmm1[127-112]= SaturateToSignedWord(xmm2/m128[111-96] - xmm2/m128[127-112]);
Opcode Instruction
64-Bit
Mode
Compat/
Leg Mode Description
0F 38 07 /r PHSUBSW
mm1,
mm2/m64
Valid Valid Subtract 16-bit signed
integer horizontally, pack
saturated integers to
MM1.
66 0F 38 07 /r PHSUBSW
xmm1,
xmm2/m128
Valid Valid Subtract 16-bit signed
integer horizontally, pack
saturated integers to
XMM1