| CSCI 464 | USING Technique Comment |
It helps to remember that when the assembler resolves operand expressions into base-displacement values, it makes a distinction between implied and explicit addresses. Explicit addresses are those in which you (the programmer) provide the values of base and displacement (or length) that should be used in the appropriate fields of the instruction; an implied address (or length) is one in which you expect the assembler to determine the values to be assigned. For example:
MVC A,B(2) 1st operand: implied address and length,
* 2nd operand: explicit displacement and base
MVC A(3),0(2) 1st operand: implied addr, explicit length
AP A,B(2) 1st operand: implied address and length,
* 2nd operand: implied addr, explicit length
L 3,X 2nd operand: implied address
*
LA 3,3(0,0) 2nd operand: explicit displ, index, and base
L 3,3(4) 2nd operand: implied (indexed) address
LA 3,3 2nd operand: implied address (NOT a
* displacement!)
Note that whether the operand format is treated as explicit or implied depends on the instruction. (Note that 3(4) is an implied address for LA, but explicit for the second operand MVC or the first operand of MVI!)
In the last two examples, the presence of an implied address means that the assembler must figure out the base and displacement. Now, it is almost always the case that these two will be treated identically: if there is no USING active for R0, the assembler will resolve the implied address "3" the same way it resolves the explicit address "3(0,0)". It is clear that if you specify all items explicitly, then
LA 2,-4(0,0)
is invalid, because -4 cannot be explicitly specified as a displacement. You could have done something risky by specifying
L 0,=H'2'
USING 2,0
LA 3,3
and the assembler will resolve the implied address "3" with displacement 1 and base register 0 (fortunately, High Level Assembler will warn you that you are using a non-zero base value in register zero!).
The process used for resolving implied addresses is the following:
Thus, the normal case of "LA 3,3" uses rule 4 to resolve the address. Now, if you want to do "interesting" things with USINGs, you can specify unusual values:
LH 4,=H'-4096'
USING -4096,4
LA 2,-4
This is perfectly valid: the assembler will find that it can assign valid base and displacement values using R4 as a base register. Even stranger things can be done:
L 5,=F'1000000'
USING 1000000,5
LA 0,1000009
The point of these examples is not to recommend a particular practice, only to show how the assembler does its work; I hope they helped.
Regards... John Ehrman (ehrman@vnet.ibm.com)