cmpi
Compare Immediate
Compares the contents of register RA with a sign-extended immediate value.
Details
The contents of register RA ((RA)32:63 sign-extended to 64 bits if L=0) are compared with the sign-extended value of the SI field, treating the operands as signed integers. The result of the comparison is placed into CR field BF.
Pseudocode Operation
if L = 0 then a ←EXTS((RA)32:63)
else a ←(RA)
if a < EXTS(SI) then c ←0b100
else if a > EXTS(SI) then c ←0b010
else c ←0b001
CR4×BF+32:4×BF+35 ←c || XERSO
Programming Note
The cmpi instruction is commonly used for signed integer comparisons where one operand is an immediate value. Be cautious with the alignment of the register RA, as incorrect alignment can lead to unexpected results. This instruction operates at user privilege level and does not generate exceptions under normal circumstances.
Extended Mnemonics
| Extended Mnemonic | Equivalent Instruction |
|---|---|
| cmpdi | |
| cmpwi |
Example
Encoding
Operands
-
BF
Condition Register Field -
L
Size (0=32-bit, 1=64-bit) -
RA
Source Register -
SI
Signed 16-bit Immediate