When i read the book the format to establish the addressability is using following code :
Code:
BALR 12,0
USING *,12
And book siad BALR is used to actually write the address into R12 at run time. But when i read the following exit code , i got two questions.
1. In this code , it not use BALR ,how to put address in R12 at run time ?
2. Why it use two USING here ? get two different address for base address? why?
Code:
EJECT
TMSXITC CSECT ,
TMSXITC AMODE 31
TMSXITC RMODE ANY
TMMLINK ENTRY,BASE=(R12),EQUS=YES,
DATA=WORKAREA,
SYSMOD=CAL0C60 CAL0C60
EJECT
SPACE 2
LR R8,R1 PARAMETER LIST
USING UX0CPARM,R8 ADDRESSABILITY
LM R9,R11,UX0CPARM LOAD ALL PARAMETERS
USING TMRECST,R10 ADDRESSABILITY
LTR R11,R11 Q. IS THIS A MULTI-VOLUME
BNZ MULTIVOL A. YES, COPY ONLY CERTAIN ELDS
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Since it is a run-time thing, it does not matter how the correct address is stored where it is needed, just that it is.
For the "why two USINGs" you should explore the difference between USING *,.. and USING somename,...
You also need to know exactly what BALR x,0 actually does. You'll see lots of other use of BALR that are nothing to do with this specific, conventional, use.
Thanks for your asnwer. as you siad "Since it is a run-time thing, it does not matter how the correct address is stored where it is needed, just that it is."
Why it does matter the correct address is used otherwise it cant find where is the program ?
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
Actually, there are at least 3 base registers -
R12, established by the TMMLINK macro, to provide addressability for the exit. The address in R12 is established by the TMMLINK macro. There are - usually - two ways to initialize a base register for a program.
Use the module's address. The convention in all operating systems derived from OS/360 is that register 15 contains the address of the module when it is entered, so you see something like this -
Code:
AMODULE CSECT
USING *,R12
SAVE (14,12),,*
LR R12,R15
...
Some expansions of the SAVE macro, by the way, and including the one used here, assume register 15 contains the address of the first instruction of the SAVE macro.
If you are unwilling to trust the common rule, you store the address yourself -
Code:
AMODULE CSECT
SAVE (14,12),,*
BALR R12,0
USING *,R12
You can determine the convention used by TMMLINK by reviewing its expansion
R8, to provide addressability to the parameter list built by the exit's caller. In turn, the data in R8 was copied from R1. At a guess the module that called TMSXITC stored the address in R1.
R10, to provide addressability to a data area defined by the TMRECST DSECT. Its address is in the parameter list.