The LINK macro is used to pass control to a specified entry name in another load module; the entry name must be a member name or an alias in the directory of a partitioned data set (PDS) or must have been specified in an IDENTIFY macro. The load module containing the program is brought into virtual storage if a usable copy is not available.
If your program is in access register (AR) address space control (ASC) mode, use LINKX. All the parameters on LINK are valid on LINKX.
LINK and LINKX processing ensure that the called program receives control in the correct addressing mode. If the called program has an address mode of ANY, it receives control in the AMODE of the calling program. The program issuing the LINK or LINKX macro regains control in its own addressing mode.
The caller optionally can provide a parameter list to be passed to the called program. If the called program terminates abnormally, or if the specified entry point cannot be located, the task is abnormally terminated unless the caller provides an ERRET exit.
The requirements for the caller of LINK are:
Environmental factor | Requirement |
---|---|
Minimum authorization: | Problem state and any PSW key. |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN=HASN=SASN |
AMODE: | 24- or 31-bit for LINK. 24- or 31- or 64-bit for LINKX. |
ASC mode: | Primary |
Interrupt Status: | Enabled for I/O and external interrupts |
Locks: | No locks held |
Control parameters: | Must be in the primary address space. |
None.
After the caller issues the macro, the system might use some registers as work registers or might change the contents of some registers. When the system returns control to the caller, the contents of these registers are not the same as they were before the macro was issued. Therefore, if the caller depends on these registers containing the same value before and after issuing the macro, the caller must save these registers before issuing the macro and restore them after the system returns control.
xxxxxxxY
where
Y is: Upon return to the caller, the GPRs contain whatever values the called program placed there.
Bits 0–31 of the 64 bit register contain the abend reason code for the abend code for the ABEND that would have been issued if the caller had not provided an ERRET exit.
Bits 32–63 of the 64 bit register contain the abend code for the ABEND that would have been issued if the caller had not provided an ERRET exit.
None.
The standard form of the LINK macro is written as follows:
Syntax | Description |
---|---|
name | name: Symbol. Begin name in column 1. |
␢ | One or more blanks must precede LINK. |
LINK | |
␢ | One or more blanks must follow LINK. |
EP=entry name | entry name: Symbol. |
EPLOC=entry name addr | entry name addr: A-type address, or register (2) - (12). |
DE=list entry addr | list entry addr: A-type address, or register (2) - (12). |
,DCB=dcb addr | dcb addr: A-type address, or register (2) - (12). |
,PARAM=(addr) | addr: A-type address, or register (2) - (12). |
,PARAM=(addr),VL=1 | Note: addr is one or more addresses, separated by commas. For example, (addr,addr,addr) |
,ID=id nmbr | id nmbr: Symbol or decimal digit, with a maximum value of 4095. |
,ERRET=err rtn addr | err rtn addr: A-type address, or register (2) - (12). |
,LSEARCH=NO | Default: No |
,LSEARCH=YES | |
The parameters are explained as follows:
Instead, the system uses the BLDL macro to construct a new list entry containing the DE information.
If the DCB parameter is omitted or if DCB=0 is specified when the LINK macro is issued by the job step task, the data sets referred to by either the STEPLIB or JOBLIB DD statement are first searched for the entry point name. If the entry point name is not found, the link library is searched.
If the DCB parameter is omitted or if DCB=0 is specified when the LINK macro is issued by a subtask, the data sets associated with one or more data control blocks referred to by the TASKLIB operand of previous ATTACH macros in the subtasking chain are first searched for the entry point name. If the entry point name is not found, the search is continued as if LINK had been issued by the job step task.
Specify VL=1 only if the called program can be passed a variable number of parameters. VL=1 causes the high-order bit of the last address parameter to be set to 1; the bit can be checked to find the end of the list.
None.
LINK EP=PGMLKRUS
LINK EP=PGMA,PARAM=((4),(6),(8))