360 Assembly/360 Instructions/BCTR
BC - Branch on Count - RX type instruction - Opcode 46
BCTR 2,4 BCTR 15,3 BCTR 7,8 BCTR 1,0 - Value in register 1 is decremented, but no branch will occur
|RR Instruction (2 bytes)|
0..F / (dec 0..15)
0..F / (dec 0..15)
- The first argument is a target register which value is affected by the instruction.
- The second argument is the branch register whose contents are to be used as the location to transfer to (if the argument is not zero).
- The target register and branch register values are 0 to 15.
- BCTR 1,9
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.
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.
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 are not changed. If the value is the lowest possible value and overflow to the highest value occurs, it is ignored.
Exceptions and Faults
- If the address to branch to contained in the branch register is not in the same PSW storage key (unless this process' storage key is 0) a protect violate exception occurs.
- If the address to branch to contained in the branch register is odd, an address exception occurs
Alternative branch instructions
- The BCT instruction provides the same functionality but with the branch address specified in Indexed Base-Displacement format.
|360 Assembly Instructions||Next Instruction
|360 Assembly Language|
|360 Family||Introduction · Basic FAQ · 360 Family · 360 Architecture|
|360 Instruction Set||360 Instructions · Branch Instructions · Data Transfer Instructions · Control Flow Instructions · Arithmetic Instructions · Logic Instructions · Shift and Rotate Instructions · Other Instructions|
|Syntaxes and Assemblers||360 Assemblers· Pseudo Instructions|
|Instruction Extensions||Floating Point · High-Level Languages|
||This page or section is an undeveloped draft or outline.
You can help to develop the work, or you can ask for assistance in the project room.