cmpl

Compare Logical

cmpl BF, L, RA, RB

Compares two registers as unsigned integers.

Details

Performs an unsigned logical comparison between RA and RB, with L determining the operand size (L=0 for 32-bit, L=1 for 64-bit). The comparison result is written to condition register field BF. The comparison sets the LT, GT, or EQ bits in the target CR field based on whether RA is less than, greater than, or equal to RB when interpreted as unsigned integers. This Base category instruction affects only the specified condition register field, not CR0.

Pseudocode Operation

if L = 0 then
  a ← zero_extend(RA[32:63], 64)
  b ← zero_extend(RB[32:63], 64)
else
  a ← RA
  b ← RB
if a < b then
  CR[BF] ← 0b100 || SO
elseif a > b then
  CR[BF] ← 0b010 || SO
else
  CR[BF] ← 0b001 || SO

Programming Note

Use cmpl for unsigned comparisons. Ensure registers RA and RB are properly aligned if they contain pointers or data structures. The instruction modifies the Condition Register (CR), so check the appropriate field after execution to determine the result of the comparison.

Example

cmpl cr1, 1, r3, r4

// Unsigned compare of r3 vs r4.

Encoding

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

Operands

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