cmp

Compare

cmp BF, L, RA, RB

Compares two registers as signed integers and records the result in the specified Condition Register Field.

Details

The fixed-point Compare instructions compare the contents of register RA with either the sign-extended value of the SI field, the zero-extended value of the UI field, or the contents of register RB. The comparison is signed for cmpi and cmp, and unsigned for cmpli and cmpl. The L field determines whether the operands are treated as 32-bit or 64-bit quantities.

Pseudocode Operation

if (RA) < (RB) then CR[BF] <- 0b1000 (LT)...

Programming Note

The cmp instruction is commonly used for signed comparisons between two registers. Ensure that the operands are correctly aligned and consider the L field to specify whether the comparison should be performed on 32-bit or 64-bit values. The result of the comparison updates the Condition Register (CR), so always check CR[BF] after executing cmp to determine the outcome.

Example

cmp cr7, 0, r3, r4

Encoding

Binary Layout
31
0
BF
6
/
9
L
10
RA
11
RB
16
0000000000
21
1
31
 
Format X-form
Opcode 0x7C000000
Extension Base
Registers Altered CR

Operands

  • BF
    Condition Register Field (0-7)
  • L
    Operand Size (0=32-bit, 1=64-bit)
  • RA
    Source Register 1
  • RB
    Source Register 2