pdepd

Parallel Bits Deposit Doubleword

pdepd RA, RS, RB

Deposits bits from RS to RA under control of mask RB (Scalar).

Details

The pdepd instruction deposits bits from the source register RS into the destination register RA based on a mask specified in the RB register. Bits from RS are placed in the least-significant positions of RA where the corresponding bits in RB are set to 1, maintaining their original order.

Pseudocode Operation

result ←0
mask ←(RB)
m ←0
k ←0
do while (m < 64)
   if (mask63-m == 1) then do
       result63-m ←(RS)63-k
      k ←k + 1
   end

Programming Note

The pdepd instruction is useful for selectively depositing bits from one register into another based on a mask. Ensure that the source and destination registers are properly aligned to avoid unexpected behavior. This instruction operates at user privilege level, but care must be taken with the mask to prevent unintended data corruption.

Example

pdepd r4, r3, r5

Encoding

Binary Layout
31
0
RS
6
RA
11
RB
16
196
21
/
31
 
Format X-form
Opcode 0x7C0000C4
Extension Base

Operands

  • RA
    Target
  • RS
    Source
  • RB
    Mask