cmplw
Compare Logical Word - 7C 00 40 00
cmplw

Instruction Syntax

MnemonicFormatFlags
cmplwcrfD, rA, rBNone

Instruction Encoding

0
1
1
1
1
1
D
D
D
A
A
A
A
A
B
B
B
B
B
0
1
0
0
0
0
FieldBitsDescription
Primary Opcode0-5011111 (0x1F)
crfD6-8Condition Register Field
rA11-15Source register A
rB16-20Source register B

Operation

CR[crfD] ← (rA) - (rB) (unsigned)

CMPLW compares the value in register rA with the value in register rB and sets the specified Condition Register field based on the result (unsigned comparison).

  1. Subtracts rB from rA (unsigned)
  2. Sets the CR field: LT, GT, EQ, SO (unsigned logic)

Note: Used for unsigned comparisons.

Affected Registers

Examples

# Compare r3 and r4 (unsigned)
cmplw r3, r4
beq is_equal
bne not_equal

# Compare for threshold (unsigned)
cmplw r5, r6
bge above_threshold

Related Instructions

cmplwi, cmpi, subf

Back to Index