cmp
Compare
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
Encoding
Operands
-
BF
Condition Register Field (0-7) -
L
Operand Size (0=32-bit, 1=64-bit) -
RA
Source Register 1 -
RB
Source Register 2