extlwi
Extract and Left Justify Immediate
Extracts a specified number of bits from the source register, left-justifies them, and places them in the target register.
Details
Extracts n bits starting at bit position b from GPR rs, left-justifies them in the target GPR ra, and zeros the remaining bits. This is a pseudo-instruction (alias) for rlwimi with specific parameters and operates in 32-bit mode. The instruction updates CR0 if the record bit (Rc) is set.
Pseudocode Operation
mask ← MASK(0, n-1)
ra ← (rs >> b) & mask
ra ← ra << (32 - n)
if Rc then CR0 ← record_cr(ra) endif
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
Encoding
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