The Load Complement instruction copies the two’s complement value (See Binary Arithmetic)  of  the contents of the register specified by Operand 2, into the register specified by Operand 1.  The contents of Operand 2 are unchanged by this operation.  Remember that if you add an integer and its two’s complement, the result is zero.  (The two’s complement of 5 is -5.  The two’s complement of -33 is 33.)  LCR sets the condition code based on the final contents of the Operand 1 register.

 

                                    Condition Code         Meaning             Test With

 

                                       0   (Zero)                 Operand 1 = 0         BE, BZ

                                       1   (Negative)          Operand 1 < 0         BL, BM

                                       2   (Positive)            Operand 1 > 0         BH, BP

                                       3   (Overflow)           Overflow                 BO

 

An overflow condition can occur only when Operand 2 contains the maximum negative value that will fit in a register (- 2,147,483,648).  An overflow occurs because the complement will not fit in a single register.

 

Consider the instruction below.  Assume R10 contains x’00000078’ = 120.

 

                            LCR   R5,R10

 

The contents of register 10 are complemented and copied to register 5, destroying the previous value in register 5. At completion, register 5 contains a binary number equivalent to -120 in decimal. Register 10, which contains a binary number equal to 120 in decimal, is unaffected by the operation.  Since the contents of R5 is negative after completion of the operation, the condition code is set to 1.  The diagram below illustrates this operation.

 

            

 

 

 

 

 

 

 

 

 

 

        Some Unrelated LCR’s

 

              R4 =  X’FFFFFFFF’  -1

              R5 =  X’00000028’  +40

              R6 =  X’80000000’  MAXIMUM NEGATIVE VALUE

              R7 =  X’00000000’  ZERO

  

 LCR    R4,R5   R4 = X’FFFFFFD8’ R5 = X’00000028’ Cond. Code = Negative

 LCR    R5,R4   R5 = X’00000001’ R4 = X’FFFFFFFF’ Cond. Code = Positive

 LCR    R5,R6   R5 = X’FFFFFFFF’ R6 = X’80000000’ Cond. Code = Overflow

 LCR    R6,R5   R6 = X’FFFFFFD8’ R5 = X’00000028’ Cond. Code = Negative

 LCR    R6,R7   R6 = X’00000000’ R7 = X’00000000’ Cond. Code = Zero

 LCR    R4,R4   R4 = X’00000001’ Cond. Code = Positive