Branch on Count (BCT, BCTR)
The BRANCHON COUNT instructions are often used to
execute a program loop for a specified number of times.
For example, assume that the following represents some lines
of coding in an assembly-language program:LUPE AR8,!
BACK BCT6,LUPE where register 6 contains 00 00 00 03 and the address of LUPE is 6826. Assume that, in order to address this loca tion, register lOis used as a base register and contains 00 00 68 00. The format of the BCT instruction is:
Machine Format
46I 6 I 0 I A 026 Assembler Format Op Code R
1
, D2 (X
2
, B
2
)
BCT6,X'26'(O,10) The effect of the coding is to execute three times the loop
defined by locationsLUPE through BACK.
Branch onIndex High (BXH)
The BRANCHON INDEX HIGH instruction is an index incrementing and loop-controlling instruction that causes a
branch whenever the sum of an index value and an increment
value is greater than some comparand. For example, assume
that:
Register 4 contains00 00 00 8A = 13810 = the index
Register 6 contains00 00 00 02 = 2
1
0 = the increment
Register 7 contains00 00 00 AA = 17010 = the comparand
Register10 contains 00 00 71 30 = the branch address
The format of the instruction is:
Machine Format
86I 4 I 6 I A 000 Assembler Format Op Code R
1
, R
3
, D2 (B
2
)
BXH4,6,0(10) When the instruction is executed: first, the contents of
register 6 are added to register 4; second, the sum iscom pared with the contents of register 7; and third, the deci sion to branch is made. After execution:
Register 4 contains00 00 00 8C=140 10 Registers 6 and 7 are unchanged
Since the new value in register 4 is not greater than the
value in register 7, the branch to address7130 is not taken.
When the register used to contain the increment is odd,
that register also becomes the comparand register. Thefol lowing assembly-language routine illustrates how this fea me may be used to search a table:
Table
Two Bytes Two Bytes
ARG1 FUNCT1
ARG2 FUNCT2
ARG3 FUNCT3
ARG4 FUNCT4
ARG5 FUNCT5
ARG6 FUNCT6
Assume that:
Register0 contains the search argument
Register 1 contains the width of the table in bytes(00 00 00 04) Register 2 contains the length of the table in bytes (00 00 00 18)
Register 3 contains the starting address of the table
Register 14 contains the return address to the main program
As the following subroutine is executed, the argument in
register0 is successively compared with the arguments in
the table, starting with argument 6 and working backwards
to argument 1. If an equality is found, the corresponding
function replaces the argument in registerO. If an equality
is not found, FF 16 replaces the argument in registerO. The first instruction (LNR) causes the value in register 1
to be made negative. After execution of this instruction,
register 1 contains FFFFFFFC =-4 10 , Considering the
case when no equality is found, the BXH instruction will
be executed seven times. Each time the BXH is executed,
a value of-- 4 is added to register 2, thus reducing the
value in register 2 by 4. The new value in register 2 iscom pared with the -4 value in register l. Thus the branch is
taken each time until the value in register 2 is -4.
SEARCH LNR 1, 1NOTEQUAL BXH 2,1, LOOP NOTFOUND LA 0, X'FF'
BCR 15, 14LOOP CH 0,0(2,3) BC 7, NOTEQUAL LH 0,2 (2,3)
BCR 15,14
Branch onI ndex low or Equal (BXlE)
This instruction is similar to BRANCHON INDEX HIGH
except that the branch is successful when the sum is low
or equal compared to the comparand.
Appendix I. Number Representation andInstruction-Use Examples 293
The BRANCH
execute a program loop for a specified number of times.
For example, assume that the following represents some lines
of coding in an assembly-language program:
BACK BCT
Machine Format
46
1
,
2
,
2
)
BCT
defined by locations
Branch on
The BRANCH
branch whenever the sum of an index value and an increment
value is greater than some comparand. For example, assume
that:
Register 4 contains
Register 6 contains
1
0
Register 7 contains
Register
The format of the instruction is:
Machine Format
86
1
,
3
,
2
)
BXH
register 6 are added to register 4; second, the sum is
Register 4 contains
Since the new value in register 4 is not greater than the
value in register 7, the branch to address
When the register used to contain the increment is odd,
that register also becomes the comparand register. The
Table
Two Bytes Two Bytes
ARG1 FUNCT1
ARG2 FUNCT2
ARG3 FUNCT3
ARG4 FUNCT4
ARG5 FUNCT5
ARG6 FUNCT6
Assume that:
Register
Register 1 contains the width of the table in bytes
Register 3 contains the starting address of the table
Register 14 contains the return address to the main program
As the following subroutine is executed, the argument in
register
the table, starting with argument 6 and working backwards
to argument 1. If an equality is found, the corresponding
function replaces the argument in register
is not found, FF 16 replaces the argument in register
to be made negative. After execution of this instruction,
register 1 contains FFFFFFFC =
case when no equality is found, the BXH instruction will
be executed seven times. Each time the BXH is executed,
a value of
value in register 2 by 4. The new value in register 2 is
taken each time until the value in register 2 is -4.
SEARCH LNR 1, 1
BCR 15, 14
BCR 15,14
Branch on
This instruction is similar to BRANCH
except that the branch is successful when the sum is low
or equal compared to the comparand.
Appendix I. Number Representation and








































































































































































































































































































































