On Wed, 8 Nov 2023 at 17:13, Farley, Peter <
[email protected]> wrote:

> The “why” of using adcons instead of direct instruction reference with my
> suggested USING setup:
>
> Because the mainline USING that I suggested limits the use of R11 to just
> the mainline code and data, the labels on your exit routines are not
> addressable using R11 since they are outside of that range of addresses.
>
> Loading an A(exitname) constant means the assembler can resolve the adcon
> value to “offset from start of code” because it knows where that name is in
> the object code, but it won’t let you use that name directly in LA or LAY
> because there is no base register that covers the area where the exit name
> is coded.  Then the loader can fully resolve the adcon value at program
> load time because the ESD entry is “CSECT start + offset”.
>

In the case where the routines are in the same assembly/CSECT, but don't
have addressibility via a register, LARL is your friend. For that matter
LARL is generally useful in all sorts of such cases. For example, where you
have a main routine and some sort of exits or callbacks that don't get
passed the original base register value, in old-style coding you might need
something like:
BALR  Rx,EXIT
USING EXIT,Rx
L     Rn,=A(MAIN)
USING MAIN,Rn

to establish a base. Now you can use

LARL Rn,MAIN
USING MAIN,Rn
to get the main base back.

Tony H.

Reply via email to