extlwi

Extract and Left Justify Immediate

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

Extracts a specified number of bits from the source register, left-justifies them, and places them in the target register.

Details

The extlwi instruction extracts 'n' bits starting at position 'b' from the source register RS and left-justifies them in the target register RA. The high-order 32 bits of the target register are preserved or rotated as needed.

Pseudocode Operation

if 'extlwi' then
    ra <- rlwinm(rs, b, 0, n-1)

Programming Note

The extlwi instruction is useful for extracting a specific bit field from a source register and left-justifying it in the target register. Ensure that the bit positions 'b' and 'n' are correctly specified to avoid data corruption. The operation preserves or rotates the high-order bits of the target register, so be aware of this behavior if you need to maintain specific register contents.

Extended Mnemonics

Extended Mnemonic Equivalent Instruction

Example

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

Encoding

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

Operands

  • ra
    Target General Purpose Register
  • rs
    Source General Purpose Register
  • n
    Number of bits to extract (must be greater than 0)
  • b
    Starting bit position for extraction