Backward indexing
To index backward through an array (from high to low storage addresses), you need a BXH test, to end the loop when the lowest address is reached. This may be achieved in two ways.
The first way uses all three keywords, with numeric values for the FROM and TO values i and j, where the FROM value i is greater than the TO value j. Although no test on the BY value k is performed, it should be negative. Also, while the FROM and TO values i and j need not be positive, they are assumed to be negative numerics if and only if a leading minus sign occurs.
DO FROM=(Rx,6),TO=(Ry+1,-6),BY=(Ry,-4)
Code for F
ENDDO
produces:
DO FROM=(R1,6),TO=(R3,-6),BY=(R2,-4)
LA R1,6
LH R3,=H'-6'
LH R2,=H'-4'
#@LB2 DC 0H
Code for F
ENDDO
#@LB3 DC 0H
BXH R1,R2,#@LB2
The other way is to omit the TO keyword. The BY value k is a negative numeric (it has a leading minus sign), indicating backward indexing. Although no test on the register number Ry is performed, it must have an odd value.
DO FROM=(Rx,=A(END-START)),BY=(Ry,-2)
Code for F
ENDDO
produces:
DO FROM=(R1,=A(END-START)),BY=(R3,-2)
L R1,=A(END-START)
LH R3,=H'-2'
#@LB2 DC 0H
Code for F
ENDDO
#@LB3 DC 0H
BXH R1,R3,#@LB2