A.5.262 PUNPCKxxx: Unpack and Interleave Data
PUNPCKHBW mm1,mm2/m64 ; 0F 68 /r [PENT,MMX]
PUNPCKHWD mm1,mm2/m64 ; 0F 69 /r [PENT,MMX]
PUNPCKHDQ mm1,mm2/m64 ; 0F 6A /r [PENT,MMX]
PUNPCKHBW xmm1,xmm2/m128 ; 66 0F 68 /r [WILLAMETTE,SSE2]
PUNPCKHWD xmm1,xmm2/m128 ; 66 0F 69 /r [WILLAMETTE,SSE2]
PUNPCKHDQ xmm1,xmm2/m128 ; 66 0F 6A /r [WILLAMETTE,SSE2]
PUNPCKHQDQ xmm1,xmm2/m128 ; 66 0F 6D /r [WILLAMETTE,SSE2]
PUNPCKLBW mm1,mm2/m32 ; 0F 60 /r [PENT,MMX]
PUNPCKLWD mm1,mm2/m32 ; 0F 61 /r [PENT,MMX]
PUNPCKLDQ mm1,mm2/m32 ; 0F 62 /r [PENT,MMX]
PUNPCKLBW xmm1,xmm2/m128 ; 66 0F 60 /r [WILLAMETTE,SSE2]
PUNPCKLWD xmm1,xmm2/m128 ; 66 0F 61 /r [WILLAMETTE,SSE2]
PUNPCKLDQ xmm1,xmm2/m128 ; 66 0F 62 /r [WILLAMETTE,SSE2]
PUNPCKLQDQ xmm1,xmm2/m128 ; 66 0F 6C /r [WILLAMETTE,SSE2]
PUNPCKxx all treat their operands as vectors, and produce a new vector
generated by interleaving elements from the two inputs. The PUNPCKHxx
instructions start by throwing away the bottom half of each input
operand, and the PUNPCKLxx instructions throw away the top half.
The remaining elements, are then interleaved into the destination,
alternating elements from the second (source) operand and the first
(destination) operand: so the leftmost part of each element in the
result always comes from the second operand, and the rightmost from the
destination.
- PUNPCKxBW works a byte at a time, producing word sized output
elements.
- PUNPCKxWD works a word at a time, producing doubleword sized output
elements.
- PUNPCKxDQ works a doubleword at a time, producing quadword sized
output elements.
- PUNPCKxQDQ works a quadword at a time, producing double quadword
sized output elements.
So, for example, for MMX operands, if the first operand held
0x7A6A5A4A3A2A1A0A and the second held 0x7B6B5B4B3B2B1B0B, then:
- PUNPCKHBW would return 0x7B7A6B6A5B5A4B4A.
- PUNPCKHWD would return 0x7B6B7A6A5B4B5A4A.
- PUNPCKHDQ would return 0x7B6B5B4B7A6A5A4A.
- PUNPCKLBW would return 0x3B3A2B2A1B1A0B0A.
- PUNPCKLWD would return 0x3B2B3A2A1B0B1A0A.
- PUNPCKLDQ would return 0x3B2B1B0B3A2A1A0A.