Branch on Index Low or Equal
This is one of several instructions that can be used to create a counted loop. The format is:
BXLE R1,R2,D(B)
Here R1 is the index register.
If R2 is even, it represents an even-odd pair: the even register is the increment register and the odd register is the limit register.
If R2 is odd, it is both the increment register and the limit register.
What does this do?
This gives us a general counted loop (bottom-tested), counting up to a value. We could, for instance, count from 7 to 300 by 13s:
L 5,=F'7' L 2,=F'13' L 3,=F'300' LOOP DS 0H whatever BXLE 2,5,LOOP
When the loop ends, execution continues with the line after BXLE.
Branch on Index High
This is similar but counts down to a value. The format is:
BXH R1,R2,D(B)
The execution is like BXLE except for:
How can we add or subtract 64-bit numbers?
When we use 64-bit numbers, they are always in two consecutive registers, even and odd. If we wanted to add two of these, we need:
Add Logical Add Logical Register
The formats for these are:
AL R,D(X,B) ALR R1,R2
Here R, R1 and R2 are even-numbered registers representing pairs of registers. The D(X,B) address must be on a doubleword boundary.
These are like Add and Add Register except that:
Result Leftmost Carry Bit CC = 0 0 0 1 not 0 0 2 0 1 3 not 0 1
We also have :
Subtract Logical Subtract Logical Register
The formats for these are:
SL R,D(X,B) SLR R1,R2
These are similar but subtract instead, and the condition code is set differently:
Result Leftmost Carry Bit CC = 0 not used 1 not 0 0 2 0 3 not 0 1
We can use these to add or subtract 64-bit values: add the two right halves, notice whether the condition code is 2 or 3, add the two left halves, and add 1 to that sum if indicated.
Move Character Long
A limitation of the MVC instruction is that it can move no more than 256 bytes at a time. If we want to move more, we need:
MVCL R1,R2
Here R1 and R2 must each be even, representing even-odd pairs of registers.
Bytes are copied, one at a time, source to destination.
If destination's length < source length, the pad character is inserted on the right.
If destructive overlap is involved, nothing moves.
Notice that this allows us to move up about 16 million bytes at a time.
Compare Logical Long
Likewise we might want to compare long character values. If so, we need:
CLCL R1,R2
The setup for this is like the setup for MVCL.
We compare bytes one at a time, left to right until either we find a difference or we reach the end.
If lengths are different, the shorter field is padded with the pad character on the right.
For each byte, R1 and R2 are each incremented by 1 and R1+1 and R2+1 are each decremented by 1. Afterward, we can use R1 and R2 to determine the point of difference.
For CLCL, the fields may overlap.