An Example - The following program is an example of the correct
use of the USING Assembler instruction, establishing addressing and the use of indexing. The program returns the sum of the binary values in TABLE as a return code in register 15. This program also illustrates the use of the BXLE instruction, another instruction that seems to scare many Assembler programmers.
LOOP A 15,TABLE(3)
TABLE DC F'1,5,-6,0'
TABSIZE EQU *-TABLE
The LR immediately after the SAVE macro call copies the entry point address in register 15 to register 12.
LA 4,L'TABLE loads the length of an entry in TABLE.
LA 5,TABSIZE-L'TABLE loads the offset of the last entry in the table into register 5.
BXLE (Branch indeX Low or Equal) is a complex instruction. First, it adds the contents of register 4 to register 3. Then it compares the contents of register 3 and register 5. If register 3 is less than or equal to register 5 it performs the branch. This is a classic use of BXLE in that registers 3 and 5 contain values suitable for indexing.
One reason why many programmers shy away from BXLE (and its companion, BXH) it uses so many registers. It's a sad truth about Assembler programmers; we tend to manage register usage very poorly, so it often seems difficult to assign three registers for a BXLE loop, two of them the even/odd pair BXLE and BXH usually require.