cmpli

Compare Logical Immediate

cmpli BF, L, RA, UI

Compares the contents of a register with an immediate value and updates the condition register.

Details

The contents of register RA ((RA)32:63 zero-extended to 64 bits if L=0) are compared with 480 || UI, treating the operands as unsigned integers. The result of the comparison is placed into CR field BF.

Pseudocode Operation

if L = 0 then a ←320 || (RA)32:63
else a ←(RA)
if      a <u (480 || UI) then c ←0b100
else if a >u (480 || UI) then c ←0b010
else                         c ←0b001
CR4×BF+32:4×BF+35 ←c || XERSO

Programming Note

The cmpli instruction is commonly used for unsigned integer comparisons where one operand is an immediate value. Be cautious with the zero-extension behavior when L=0, as it can lead to unexpected results if not accounted for. This instruction operates at user privilege level and does not generate exceptions under normal circumstances.

Extended Mnemonics

Extended Mnemonic Equivalent Instruction
cmpldi

Example

cmpli cr0, 0, r3, 0xFF

Encoding

Binary Layout
10
0
BF
6
/
7
L
9
RA
16
UI
 
Format D-form
Opcode 0x28000000
Extension Base
Registers Altered CR, XER

Operands

  • BF
    Condition Register Field
  • L
    Size
  • RA
    Source Register
  • UI
    Unsigned 16-bit Immediate
  • CRb
    Condition Register Field
  • SIMM
    Signed Immediate Value