cmplwi
Compare Logical Immediate - 28 00 00 00
cmplwi

Instruction Syntax

MnemonicFormatFlags
cmplwicrfD, rA, UIMMNone

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
FieldBitsDescription
Primary Opcode0-5011010 (0x1A)
crfD6-8Condition Register Field
rA11-15Source register
UIMM16-31Unsigned 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).

  1. Subtracts the unsigned immediate value from the register
  2. Sets the CR field: LT, GT, EQ, SO (unsigned logic)

Note: Used for unsigned comparisons. For signed, use cmpwi.

Affected Registers

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

Related Instructions

cmplw, cmpwi, cmpi, subf

Back to Index