rlwinm
Rotate Left Word Immediate then AND with Mask - 54 00 00 00
rlwinm
Instruction Syntax
Mnemonic | Format | Flags |
rlwinm | rA,rS,SH,MB,ME | Rc = 0 |
rlwinm. | rA,rS,SH,MB,ME | Rc = 1 |
Instruction Encoding
0
1
0
1
0
1
S
S
S
S
S
A
A
A
A
A
H
H
H
H
H
B
B
B
B
B
E
E
E
E
E
Rc
Field | Bits | Description |
Primary Opcode | 0-5 | 010101 (0x15) |
rS | 6-10 | Source register |
rA | 11-15 | Destination register |
SH | 16-20 | Shift amount (0-31) |
MB | 21-25 | Mask begin bit (0-31) |
ME | 26-30 | Mask end bit (0-31) |
Rc | 31 | Record Condition Register |
Operation
rA ← ROTATE((rS), SH) & MASK
The source value (rS) is rotated left by SH positions, then ANDed with MASK (bits MB to ME). The result is placed into rA.
Note: MASK is a field mask where bits MB through ME are set to 1, and all other bits are 0.
Affected Registers
General Purpose Registers (GPRs)
- rA (Destination register)
Condition Register (CR0 field)
(if Rc = 1)
- LT (Less Than)
- GT (Greater Than)
- EQ (Equal)
- SO (Summary Overflow)
Examples
Basic Rotation and Masking
# Rotate r1 left by 8 positions and mask bits 16-23 rlwinm r2, r1, 8, 16, 23
Field Extraction
# Extract bits 4-7 from r1 rlwinm r2, r1, 0, 4, 7
Shift and Mask
# Shift r1 left by 2 and mask to 8 bits rlwinm r2, r1, 2, 24, 31