You may use two standard methods for passing control to another control section and providing for return of control. One is an extension of the method used to pass control without a return, and requires a V-type address constant and a branch, a branch and link, or a branch and save instruction provided both programs execute in the same addressing mode. If the addressing mode changes, use a branch and save and set mode instruction. The other method uses the CALL macro to provide a parameter list and establish the entry and return addresses. With either method, you must identify the entry point by an ENTRY instruction in the called control section if the entry name is not the same as the control section CSECT name. Figure 1 and Figure 2 illustrate the two methods of passing control; in each example, assume that register 13 already contains the address of a new save area.
.
.
L 15,NEXTADDR Entry address in register 15
CNOP 0,4
BAL 1,GOOUT Parameter list address in register 1
PARMLIST DS 0A Start of parameter list
DCBADDRS DC A(INDCB) Input DCB address
DC A(OUTDCB) Output DCB address
ANSWERAD DC A(AREA+X'80000000') Answer area address with
high-order bit on
NEXTADDR DC V(NEXT) Address of entry point
GOOUT BALR 14,15 Pass control; register 14 contains
return address and current AMODE
RETURNPT ...
AREA DC 12F'0' Answer area from NEXT
CALL NEXT,(INDCB,OUTDCB,AREA),VL
RETURNPT ...
AREA DC 12F'0'
Control is passed to NEXT using a branch and link instruction. (Optionally, you can specify either a BASR or BASSM instruction, with the LINKINST= parameter.) The address of the instruction following the CALL macro is loaded into register 14 before control is passed.
In addition to the results described above, the V-type address constant generated by the CALL macro requires the load module with the entry point NEXT to be link edited into the same load module as the control section containing the CALL macro. The z/OS MVS Program Management: User's Guide and Reference and z/OS MVS Program Management: Advanced Facilitiespublications tell more about this service.
CALL NEXT,(INDCB,(6),(7)),VL
In the above CALL macro, two of the parameters to be passed are coded as registers rather than symbolic addresses. The expansion of this macro again results in a three-word parameter list; in this example, however, the expansion also contains instructions that store the contents of registers 6 and 7 in the second and third words, respectively, of the parameter list. The high-order bit in the third word is set to 1 after register 7 is stored. You can specify as many address parameters as you need, and you can use symbolic addresses or register contents as you see fit.