extrwi
Extract and Right-shift Word Immediate - 7C 00 2E 30
extrwi
Instruction Syntax
Mnemonic | Format | Flags |
extrwi | rA, rS, n, b | None |
Instruction Encoding
0
1
1
1
1
1
S
S
S
S
S
A
A
A
A
A
n
n
n
n
n
n
b
b
b
b
b
1
0
1
1
1
0
Field | Bits | Description |
Primary Opcode | 0-5 | 011111 (0x1F) |
rS | 6-10 | Source register |
rA | 11-15 | Destination register |
n | 16-20 | Number of bits to extract |
b | 21-25 | Starting bit position |
Operation
rA ← (rS >> b) & ((1 << n) - 1)
EXTRWI extracts n bits from the source register rS, starting at bit position b, right-shifts them, and stores the result in rA.
- Right-shifts rS by b bits
- Masks the lower n bits
- Stores the result in rA
Note: Used for bitfield extraction and manipulation.
Affected Registers
- rA (Destination register)
Examples
# Extract 8 bits from bit 16 extrwi r3, r4, 8, 16 # Extract lower 4 bits extrwi r5, r6, 4, 0