cmpdi

Compare Doubleword Immediate

cmpdi bf,ra,si

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

Encoding

Binary Layout
11
0:5
BF
6:8
/
9
L
10
RA
11:15
SI
16:31
 
Format XO-form
Opcode 0x2C200000
Extension Base

Operands

  • bf
    Target Condition Register Field
  • ra
    Source General Purpose Register
  • si
    Signed Immediate Value

Example

cmpdi bf, ra, si

Registers Altered

CR0, CR1-CR7

Related

More in Base

Reference

Description

For cmpdi, the immediate value SI is compared with the contents of register RA. The result is placed into CR Field BF.

Operation

if 'cmpdi' then
    if (RA) < SI then CR[bF] <- 0b00000001
    else if (RA) > SI then CR[bF] <- 0b00000010
    else CR[bF] <- 0b00000100

Extended Mnemonics

Extended Mnemonic Equivalent Instruction

Programming Note

Use cmpdi to compare a register with an immediate value and set the condition register field accordingly. Ensure the immediate value fits within the signed 16-bit range. The comparison result is used in conditional branches, so check CR Field BF after execution.