The Compare Register instruction is used to compare a binary fullword in a register, designated by Operand 1, with another fullword in a register, designated by Operand 2.  The operands are compared as 32-bit signed binary integers.  The instruction sets the condition code to indicate how Operand 1 compares to Operand 2:

                              

                      Condition Code               Meaning                            Test With

 

                                0                    Operand 1 = Operand 2                 BE, BZ

                                1                    Operand 1 < Operand 2                 BL, BM

                                2                    Operand 1 > Operand 2                 BH, BP

                             

   The following example sets the condition code by comparing registers 9 and 6.

 

                            CR    R9,R6       

 

     

 

   The contents of the fullword in register 9, x’FFFFFFFF’ = -1, is compared to the contents of register 6 which contains x’000001AF’ = 431.  Since the contents of the Operand 1 register is less than the contents of the Operand 2 register, the condition code is set to “Low”.  The condition code in the diagram above is specified using 2 binary digits.  After comparison, the condition code is set to a binary 01 which is 1 in decimal - a “Low” condition.

 

 

 

 

 

 

         Some Unrelated Compare Registers

 

              R4 =  X’FFFFFFD5’  -43 IN 2’S COMPLEMENT

              R5 =  X’00000028’  +40 IN 2’S COMPLEMENT

              R6 =  X’00000004’   +4 IN 2’S COMPLEMENT

 

              CR    R4,R5    CONDITION CODE = LOW

              CR    R5,R4    CONDITION CODE = HIGH

              CR    R4,R4    CONDITION CODE = EQUAL

              CR    R6,R5    CONDITION CODE = LOW

              CR    R5,R5    CONDITION CODE = EQUAL