411 REFERENCE · Wikibooks
360 Assembly/360 Instructions/BCTR
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
__TOC__
BC - Branch on Count - RX type instruction - Opcode 46
Format
BCTR 2,4
BCTR 15,3
BCTR 7,8
BCTR 1,0 - Value in register 1 is decremented, but no branch will occur
Opcode
06 B
Example usage
BCTR 1,9
Availability
The BCTR instruction is available on all models.
Purpose of Instruction
The BCTR instruction subtracts 1 from the value of the contents of the target register specified in the first argument. If the value in the target register after the subtraction is zero (or the branch register is 0), no branch occurs. Otherwise the program branches to the address contained in the branch register specified in the second argument. Note that if the result in the target register before subtraction is 0, the result is negative 1 and the branch occurs (unless the branch register is 0). If the value in the target register is the lowest possible value, the overflow that occurs is ignored, the result in the target register is the highest possible value, and the branch occurs (unless the branch register is 0). A BCTR 0,0 instruction is the equivalent of decrementing register 0 by 1.
Typical Usage
To do a loop statement where 1 is subtracted from the value contained in the target register, and a branch should occur to the address contained in the branch register if the result isn't 0.
Operation
The value contained in the register specified as the first argument is reduced by 1. If the branch register is 0, or the value after subtraction of the value in the target register is 0, execution continues with the instruction following this instruction. Otherwise, execution transfers to the address contained in the register specified as the second argument.
Condition Codes
Condition codes are not changed. If the value is the lowest possible value and overflow to the highest value occurs, it is ignored.
Exceptions and Faults
Alternative branch instructions
The BCT instruction provides the same functionality but with the branch address specified in Indexed Base-Displacement format.
BCR BCTG 45 BAL 47 BC