extldi

Extract and Left Justify Immediate

extldi ra,rs,n,b (n > 0)

Extracts a field of n bits starting at bit position b in the source register, left justifies this field in the target register, and clears all other bits of the target register to 0.

Encoding

Binary Layout
18
0:5
LI
6:29
AA
30
LK
31
 
Format XO-form
Opcode 0x78000004
Extension Base

Operands

  • ra
    Target General Purpose Register
  • rs
    Source General Purpose Register
  • n
    Number of bits to extract
  • b
    Starting bit position

Example

extldi ra, rs, n, b (n > 0)

Related

More in Base

Reference

Description

For extldi, the field of n bits starting at bit position b in the source register is extracted, left justified in the target register, and all other bits are cleared to 0.

Operation

if 'extldi' then
    ra <- (rs >> b) & ((1 << n) - 1)

Programming Note

Use extldi to extract a specific bit field from a source register, left-justifying it in the target register. Ensure that the bit position and length are correctly specified to avoid data corruption. This instruction operates at user privilege level.