Last modified on 24 June 2013, at 03:50

360 Assembly/360 Instructions/BCT

BC - Branch on Count - RX type instruction - Opcode 46

FormatEdit

   BCT 2,LABEL
   BCT 15,106(10)
   BCT 0,256(7,6)

The specific syntax is

BCT target_register,offset(index_register,base_register)

Where the target, index_register and base_register values will be determined automatically by the assembler if the USING pseudo-instruction has been used, and the target address label used is within 4096 bytes of the value of some base register.

OpcodeEdit

RX Instruction (4 bytes)
Byte 1 Byte 2 Bytes 3 and 4
target register Branch address
(In Hex) (8 bits)
Opcode
46
(4 bits)

0..F
(4 bits)
index
register

0..F
(4 bits)
base
register

0..F
(12 bits)
displacement
0..FFF
  • The first argument is a target register which value is affected by the instruction.
  • The second argument is the address to branch to. This consists of a base register, an index register, and a displacement address. The displacement is used as an unsigned offset of 0 to 4095 from the value in the base register, and this displacement is added to the value contained in the base register. If the index register is 0, it is ignored; otherwise, its contents are added to the previous result to obtain the final address.
  • The base_register and index_register values are 0 to 15. The offset address is 0 to 4095.

Example usageEdit

BCT 1,Label

AvailabilityEdit

The BCT instruction is available on all models.

Purpose of InstructionEdit

The BCT 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, no branch occurs. Otherwise the program branches to the specified address. Note that if the result in the target register before subtraction is 0, the result is negative 1 and the branch occurs. If the value in the target register before subtraction is the smallest possible value, the result is the highest possible value, the overflow is ignored and the branch occurs.

Typical UsageEdit

To do a loop statement where 1 is subtracted from the value contained in the target register, and a branch should occur if the result is not 0.

OperationEdit

The value contained in the target register specified as the first argument is reduced by 1. If the value after subtraction is 0, execution continues with the instruction following this instruction. Otherwise, execution transfers to the address specified as the second argument.

Condition CodesEdit

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 FaultsEdit

  • If the address to branch to 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 is odd, an address exception occurs

Alternative branch instructionsEdit

  • The BCTR instruction provides the same functionality but with the branch address in another register.


Previous Instruction
BCR
360 Assembly Instructions Next Instruction
BCTG
Previous Opcode
45
Next Opcode
47