rldimi

Rotate Left Doubleword Immediate Mask Insert

rldimi RA, RS, SH, MB

Rotates 64-bit value and inserts into target under mask.

Details

Rotates the 64-bit contents of RS left by SH positions and inserts the result into RA under a mask defined by MB and (63-SH), leaving other bits in RA unchanged. The condition register CR0 is updated if Rc=1.

Pseudocode Operation

n ← SH
mask ← MASK(MB, 63 - n)
rotated ← ROTL64(RS, n)
RA ← (RA & ¬mask) | (rotated & mask)
if Rc = 1 then CR0 ← (RA < 0, RA > 0, RA = 0, SO)

Programming Note

The rldimi instruction is useful for performing masked left rotations on 64-bit values. Ensure that the shift amount (SH) and mask bits (MB) are within valid ranges to avoid undefined behavior. This instruction operates at user privilege level and does not generate exceptions under normal conditions, but incorrect usage can lead to unexpected results.

Example

rldimi r4, r3, 3, 0

Encoding

Binary Layout
30
0
RS
6
RA
11
SH
16
MB
21
3
27
SH
31
 
Format MD-form
Opcode 0x7800000C
Extension Base

Operands

  • RA
    Target
  • RS
    Source
  • SH
    Shift
  • MB
    Mask Begin