Machine Format Op Code R1
46 6 o A
Assembler Format BCT The effect of the coding is to execute
three times the loop defined by the
instructions labeled lUPE through BACK, while register 6 is decremented from
three to zero. BRANCH ON INDEX HIGH (BXH)
BXH Example !
The BRANCH ON 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 compare value. For example, assume that: Register 4 contains 00 00 00 8A
= 138{10} =
the index.
Register 6 contains 00 00 00 02 = 2{10} =
the increment.
Register 7 contains 00 00 00 AA
= 170{10} = the compare value.
Register 10 contains 00 00 71 30 =
the
branch address.
The format of the BXH instruction is:
Machine Format Op Code R1
86 4 6 A I 0001 Assembler Format
BXH 4,6,0(10) When the instruction is executed, first
the contents of register 6 are added to
register 4, second the sum is compared
with the contents of register 7, and
third the decision whether to branch is
made. After execution:
Register 4 contains 00 00 00 8C = 140{10}. Registers 6 and 7 are unchanged.
Since the new value in register 4 is not
yet greater than the value in register 7, the branch to address 7130 is not
taken. Repeated use of the instruction
will eventually cause the branch to be
taken when the value in register 4
reaches 172{10}. BXH Example Z. When the register used to contain the
increment is odd, that register also
becomes the compare-value register. The
following assembler-language subroutine
illustrates how this may be used to
search a table.
Table
2 Bytes 2 Bytes
ARG1 FUNCT1 ARG2 FUNCT2 ARG3 FUNCT3 ARG4 FUNCT4 ARG5 FUNCT5 ARG6 FUNCT6 Assume that:
Register 8 contains the search
argument.
Register 9 contains the width of the
table in bytes (00 00 00 04). Register 10 contains the length of the
table in bytes (00 00 00 18).
Register 11 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 8 is succes­
sively compared with the arguments in
the table, starting with argument 6 and
working backward to argument 1. If an
equality is found, the corresponding
function replaces the argument in regis­
ter 8. If an equality is not found,
zero replaces the argument in register
8. SEARCH lNR 9,9
NOTEQUAl BXH 10,9,lOOP NOT FOUND SR 8,8 BCR 15,14 lOOP CH 8,0(10,11) BC 7,NOTEQUAl
lH 8,2(10,11) BCR 15,14
The first instruction (lNR) causes the
value in register 9 to be made negative.
After execution of this instruction,
register 9 contains FF FF FF Fe = -4{10}. Considering the case when no
equality is found, the BXH instruction Appendix A. Number Representation and Instruction-Use Examples A-I1
will be executed seven times. Each time
BXH is executed, a value of -4 is added
to register 10, thus reducing the value in register 10 by 4. The new value in register 10 is compared with the -4
value in register 9. The branch is
taken each time until the value in
register 10 is -4. Then the branch is
not taken, and the SR instruction sets
register 8 to zero.
BRANCH ON INDEX LOW OR EQUAL (BXLE)
The BRANCH ON INDEX LOW OR EQUAL
instruction performs the same operation
as BRANCH ON INDEX HIGH, except that
branching occurs when the sum is lower
than or equal to (instead of higher
than) the compare value. As the
instruction which increments and tests
an index value in a program loop, BXLE
is useful at the end of the loop and BXH
at the beginning. The following
assembler-language routines illustrate
loops with BXLE.
BXlE Example!
Assume that a group of ten 32-bit signed
binary integers are stored at consec­
utive locations, starting at location GROUP. The integers are to be added
together, and the sum is to be stored at
location SUM. LOOP SR
LA
SR
LA
LA
A
BXLE
ST 5,5 6,GROUP 7,7 8,4
9,39 5,0(7,6) 7,8,LOOP 5,SUM
Set sum to zero
Load first address
Set index to zero
Load increment 4
Load compare value
Add integer to sum
Test end of loop
Store sum
The two-instruction loop contains an ADD
(A) instruction which adds each integer
to the contents of general register 5.
The ADD instruction uses the contents of
general register 7 as an index value to
modify the starting address obtained
from register 6. Next, BXLE increments
the index value by 4, the increment
previously loaded into register 8, and
compares it with the compare value in
register 9, the odd register of this
even-odd pair. The compare value was
previously set to 39, which is one less
than the number of bytes in the data
area; this is also the address, relative
to the starting address, of the right­
most byte of the last integer to be added. When the last integer has been A-12 System/370 Principles of Operation added, BXLE
to the next
is found to
value (39)
place.
increments the index value
relative address (40), which be greater than the compare
so that no branching takes
BXLE Example The technique illustrated in Example 1
is restricted to loops containing
instructions in the RX instruction
format. That format allows both a base
register and an index register to be specified (double indexing).
For instructions in other formats, where
an index register cannot be specified,
the previous technique may be modified
by having the address itself serve as
the index value in a BXLE instruction
and by using as the compare value the
address of the last byte rather than its
relative address. The base register
then provides the address directly at
each iteration of the loop, and it is
not necessary to specify a second regis­
ter to hold the index value (single
indexing).
In the following example, an AND (NI)
instruction in the SI instruction format
sets to zero the rightmost bit of each
of the same group of integers as in
Example 1, thus making all of them even.
The 12 field of the HI instruction
contains the byte X'FE', which consists
of seven ones and a zero. That byte is
AHDed into byte 3, the rightmost byte,
of each of the integers in turn.
LA 6,GROUP LA 8,4 LA 9,GROUP+39 lOOP NI 3(6),X'FE'
BXLE 6,8,LOOP COMPARE HALFWORD (CH)
Load first address
Load increment 4
Load compare value
AHD immediate
Test end of loop
The COMPARE HAlFWORD instruction
compares a 16-bit signed binary integer in storage with the contents of a regis­
ter. For example, assume that:
Register 4 contains FF FF 80 00 = -32,768{10}. Register 13 contains 00 01 60 50. Storage locations 16080-16081 contain 8000 = -32,768{10}. When the instruction:
Previous Page Next Page