cmplw
Compare Logical Word - 7C 00 40 00
cmplw
Instruction Syntax
Mnemonic | Format | Flags |
cmplw | crfD, rA, rB | None |
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
Field | Bits | Description |
Primary Opcode | 0-5 | 011111 (0x1F) |
crfD | 6-8 | Condition Register Field |
rA | 11-15 | Source register A |
rB | 16-20 | Source 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).
- Subtracts rB from rA (unsigned)
- Sets the CR field: LT, GT, EQ, SO (unsigned logic)
Note: Used for unsigned comparisons.
Affected Registers
- Condition Register (CR field specified by crfD)
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