ia32-64/x86/pextrb.pextrd.pextrq.html

193 lines
7.9 KiB
HTML
Raw Permalink Normal View History

2025-07-08 02:23:29 -03:00
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:x86="http://www.felixcloutier.com/x86"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><link rel="stylesheet" type="text/css" href="style.css"></link><title>PEXTRB/PEXTRD/PEXTRQ
— Extract Byte/Dword/Qword</title></head><body><header><nav><ul><li><a href='index.html'>Index</a></li><li>December 2023</li></ul></nav></header><h1>PEXTRB/PEXTRD/PEXTRQ
— Extract Byte/Dword/Qword</h1>
<table>
<tr>
<th>Opcode/Instruction</th>
<th>Op/ En</th>
<th>64/32 bit Mode Support</th>
<th>CPUID Feature Flag</th>
<th>Description</th></tr>
<tr>
<td>66 0F 3A 14 /r ib PEXTRB reg/m8, xmm2, imm8</td>
<td>A</td>
<td>V/V</td>
<td>SSE4_1</td>
<td>Extract a byte integer value from xmm2 at the source byte offset specified by imm8 into reg or m8. The upper bits of r32 or r64 are zeroed.</td></tr>
<tr>
<td>66 0F 3A 16 /r ib PEXTRD r/m32, xmm2, imm8</td>
<td>A</td>
<td>V/V</td>
<td>SSE4_1</td>
<td>Extract a dword integer value from xmm2 at the source dword offset specified by imm8 into r/m32.</td></tr>
<tr>
<td>66 REX.W 0F 3A 16 /r ib PEXTRQ r/m64, xmm2, imm8</td>
<td>A</td>
<td>V/N.E.</td>
<td>SSE4_1</td>
<td>Extract a qword integer value from xmm2 at the source qword offset specified by imm8 into r/m64.</td></tr>
<tr>
<td>VEX.128.66.0F3A.W0 14 /r ib VPEXTRB reg/m8, xmm2, imm8</td>
<td>A</td>
<td>V<sup>1</sup>/V</td>
<td>AVX</td>
<td>Extract a byte integer value from xmm2 at the source byte offset specified by imm8 into reg or m8. The upper bits of r64/r32 is filled with zeros.</td></tr>
<tr>
<td>VEX.128.66.0F3A.W0 16 /r ib VPEXTRD r32/m32, xmm2, imm8</td>
<td>A</td>
<td>V/V</td>
<td>AVX</td>
<td>Extract a dword integer value from xmm2 at the source dword offset specified by imm8 into r32/m32.</td></tr>
<tr>
<td>VEX.128.66.0F3A.W1 16 /r ib VPEXTRQ r64/m64, xmm2, imm8</td>
<td>A</td>
<td>V/I<sup>2</sup></td>
<td>AVX</td>
<td>Extract a qword integer value from xmm2 at the source dword offset specified by imm8 into r64/m64.</td></tr>
<tr>
<td>EVEX.128.66.0F3A.WIG 14 /r ib VPEXTRB reg/m8, xmm2, imm8</td>
<td>B</td>
<td>V/V</td>
<td>AVX512BW</td>
<td>Extract a byte integer value from xmm2 at the source byte offset specified by imm8 into reg or m8. The upper bits of r64/r32 is filled with zeros.</td></tr>
<tr>
<td>EVEX.128.66.0F3A.W0 16 /r ib VPEXTRD r32/m32, xmm2, imm8</td>
<td>B</td>
<td>V/V</td>
<td>AVX512DQ</td>
<td>Extract a dword integer value from xmm2 at the source dword offset specified by imm8 into r32/m32.</td></tr>
<tr>
<td>EVEX.128.66.0F3A.W1 16 /r ib VPEXTRQ r64/m64, xmm2, imm8</td>
<td>B</td>
<td>V/N.E.<sup>2</sup></td>
<td>AVX512DQ</td>
<td>Extract a qword integer value from xmm2 at the source dword offset specified by imm8 into r64/m64.</td></tr></table>
<blockquote>
<p>1. In 64-bit mode, VEX.W1 is ignored for VPEXTRB (similar to legacy REX.W=1 prefix in PEXTRB).</p>
<p>2. VEX.W/EVEX.W in non-64 bit is ignored; the instructions behaves as if the W0 version is used.</p></blockquote>
<h2 id="instruction-operand-encoding">Instruction Operand Encoding<a class="anchor" href="#instruction-operand-encoding">
</a></h2>
<table>
<tr>
<th>Op/En</th>
<th>Tuple Type</th>
<th>Operand 1</th>
<th>Operand 2</th>
<th>Operand 3</th>
<th>Operand 4</th></tr>
<tr>
<td>A</td>
<td>N/A</td>
<td>ModRM:r/m (w)</td>
<td>ModRM:reg (r)</td>
<td>imm8</td>
<td>N/A</td></tr>
<tr>
<td>B</td>
<td>Tuple1 Scalar</td>
<td>ModRM:r/m (w)</td>
<td>ModRM:reg (r)</td>
<td>imm8</td>
<td>N/A</td></tr></table>
<h2 id="description">Description<a class="anchor" href="#description">
</a></h2>
<p>Extract a byte/dword/qword integer value from the source XMM register at a byte/dword/qword offset determined from imm8[3:0]. The destination can be a register or byte/dword/qword memory location. If the destination is a register, the upper bits of the register are zero extended.</p>
<p>In legacy non-VEX encoded version and if the destination operand is a register, the default operand size in 64-bit mode for PEXTRB/PEXTRD is 64 bits, the bits above the least significant byte/dword data are filled with zeros. PEXTRQ is not encodable in non-64-bit modes and requires REX.W in 64-bit mode.</p>
<p>Note: In VEX.128 encoded versions, VEX.vvvv is reserved and must be 1111b, VEX.L must be 0, otherwise the instruction will #UD. In EVEX.128 encoded versions, EVEX.vvvv is reserved and must be 1111b, EVEX.L”L must be 0, otherwise the instruction will #UD. If the destination operand is a register, the default operand size in 64-bit mode for VPEXTRB/VPEXTRD is 64 bits, the bits above the least significant byte/word/dword data are filled with zeros.</p>
<h2 id="operation">Operation<a class="anchor" href="#operation">
</a></h2>
<pre>CASE of
PEXTRB: SEL := COUNT[3:0];
TEMP := (Src &gt;&gt; SEL*8) AND FFH;
IF (DEST = Mem8)
THEN
Mem8 := TEMP[7:0];
ELSE IF (64-Bit Mode and 64-bit register selected)
THEN
R64[7:0] := TEMP[7:0];
r64[63:8] := ZERO_FILL; };
ELSE
R32[7:0] := TEMP[7:0];
r32[31:8] := ZERO_FILL; };
FI;
PEXTRD:SEL := COUNT[1:0];
TEMP := (Src &gt;&gt; SEL*32) AND FFFF_FFFFH;
DEST := TEMP;
PEXTRQ: SEL := COUNT[0];
TEMP := (Src &gt;&gt; SEL*64);
DEST := TEMP;
EASC:
</pre>
<h3 id="vpextrtd-vpextrq">VPEXTRTD/VPEXTRQ<a class="anchor" href="#vpextrtd-vpextrq">
</a></h3>
<pre>IF (64-Bit Mode and 64-bit dest operand)
THEN
Src_Offset := imm8[0]
r64/m64 := (Src &gt;&gt; Src_Offset * 64)
ELSE
Src_Offset := imm8[1:0]
r32/m32 := ((Src &gt;&gt; Src_Offset *32) AND 0FFFFFFFFh);
FI
</pre>
<h3 id="vpextrb---dest=m8-">VPEXTRB ( dest=m8)<a class="anchor" href="#vpextrb---dest=m8-">
</a></h3>
<pre>SRC_Offset := imm8[3:0]
Mem8 := (Src &gt;&gt; Src_Offset*8)
</pre>
<h3 id="vpextrb---dest=reg-">VPEXTRB ( dest=reg)<a class="anchor" href="#vpextrb---dest=reg-">
</a></h3>
<pre>IF (64-Bit Mode )
THEN
SRC_Offset := imm8[3:0]
DEST[7:0] := ((Src &gt;&gt; Src_Offset*8) AND 0FFh)
DEST[63:8] := ZERO_FILL;
ELSE
SRC_Offset := imm8[3:0];
DEST[7:0] := ((Src &gt;&gt; Src_Offset*8) AND 0FFh);
DEST[31:8] := ZERO_FILL;
FI
</pre>
<h2 id="intel-c-c++-compiler-intrinsic-equivalent">Intel C/C++ Compiler Intrinsic Equivalent<a class="anchor" href="#intel-c-c++-compiler-intrinsic-equivalent">
</a></h2>
<pre>PEXTRB int _mm_extract_epi8 (__m128i src, const int ndx);
</pre>
<pre>PEXTRD int _mm_extract_epi32 (__m128i src, const int ndx);
</pre>
<pre>PEXTRQ __int64 _mm_extract_epi64 (__m128i src, const int ndx);
</pre>
<h2 id="flags-affected">Flags Affected<a class="anchor" href="#flags-affected">
</a></h2>
<p>None.</p>
<h2 class="exceptions" id="simd-floating-point-exceptions">SIMD Floating-Point Exceptions<a class="anchor" href="#simd-floating-point-exceptions">
</a></h2>
<p>None.</p>
<h2 class="exceptions" id="other-exceptions">Other Exceptions<a class="anchor" href="#other-exceptions">
</a></h2>
<p>Non-EVEX-encoded instruction, see <span class="not-imported">Table 2-22</span>, “Type 5 Class Exception Conditions.”</p>
<p>EVEX-encoded instruction, see <span class="not-imported">Table 2-57</span>, “Type E9NF Class Exception Conditions.”</p>
<p>Additionally:</p>
<table>
<tr>
<td rowspan="2">#UD</td>
<td>If VEX.L = 1 or EVEX.LL &gt; 0.</td></tr>
<tr>
<td>If VEX.vvvv != 1111B or EVEX.vvvv != 1111B.</td></tr></table><footer><p>
This UNOFFICIAL, mechanically-separated, non-verified reference is provided for convenience, but it may be
inc<span style="opacity: 0.2">omp</span>lete or b<sub>r</sub>oke<sub>n</sub> in various obvious or non-obvious
ways. Refer to <a href="https://software.intel.com/en-us/download/intel-64-and-ia-32-architectures-sdm-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4">Intel® 64 and IA-32 Architectures Software Developers Manual</a> for anything serious.
</p></footer></body></html>