Compare instructions:

  RX Format: label  C  R,D(X,B)
  
    - Compares the fullword in R with the fullword at D(X,B)
    
    Sets the Condition Code
    
      Code     Meaning
       0       Equality
       1       Fullword in R is less than fullword at D(X,B)
       2       Fullword in R is greater than fullword at D(X,B)


  RR Format: label  CR  R1,R2

    - Compares the value in R1 to the value in R2
    
    Sets the Condition Code
    
      Code   Meaning
       0     Equality
       1     Contents of R1 is less than the contents of R2
       2     Contents of R1 is greater than the contents of R2

 

Branching

Conditional Branch

  - used to alter the flow of program execution depending on the 
    Condition Code set by an instruction
    
  RR Format: label  BCR  B‘mask’,R
  
    - mask is a 4 bit binary mask indicating which Condition 
      Codes to branch on
      
    - R is the register with the address to branch to


  RX Format: label  BC   B‘mask’,D(X,B)
  
    - mask is a 4 bit binary mask indicating which Condition 
      Codes to branch on
      
    - D(X,B) is the address to branch to


  B‘mask’  ==>  B‘bbbb’==>  B‘0123’  
  
     where 0123 represent the possible condition codes
     
     If b is 1, branch to the address in R on this Condition code.
     
     If b is 0, don’t branch.


  AR  3,4
  BC  B‘1000’,HERE      branch to the label HERE if the result of the 
                        addition is 0


  SR  3,4
  BC  B‘1100’,THERE     branch to the label THERE if the result is 
                        equal to 0 or less than zero


       XREAD BUFFER,80
  DO1  BC    B‘0100’,ENDDO1  branch to ENDDO1 if end of file is reached


  NOTE: Using the mask B‘1111’, makes an unconditional branch (it 
        will always branch)

Unconditional Branch

- Branches to a specific address no matter what the Condition Code is RX Format: B D(X,B) - Branches to D(X,B) RR Format: BR R - Branches to the address in R

Now we can write decision structures (Ifs) and repetition structures (LOOPs).