cmplwi
Compare Logical Immediate - 28 00 00 00
cmplwi
Instruction Syntax
Mnemonic | Format | Flags |
cmplwi | crfD, rA, UIMM | None |
Instruction Encoding
0
0
1
0
1
0
D
D
D
A
A
A
A
A
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
Field | Bits | Description |
Primary Opcode | 0-5 | 011010 (0x1A) |
crfD | 6-8 | Condition Register Field |
rA | 11-15 | Source register |
UIMM | 16-31 | Unsigned immediate value (16-bit) |
Operation
CR[crfD] ← (rA) - UIMM (unsigned)
CMPLWI compares the value in register rA with a 16-bit unsigned immediate value and sets the specified Condition Register field based on the result (unsigned comparison).
- Subtracts the unsigned immediate value from the register
- Sets the CR field: LT, GT, EQ, SO (unsigned logic)
Note: Used for unsigned comparisons. For signed, use cmpwi.
Affected Registers
- Condition Register (CR field specified by crfD)
Examples
# Compare r3 with 0 (unsigned) cmplwi r3, 0 beq is_zero bne not_zero # Compare for threshold (unsigned) cmplwi r4, 100 bge above_threshold