This is correct.
The "main" program
EXWTO CSECT
USING *,12
SAVE (14,12),,*
LR 12,15
L 1,=V(WTO1)
WTO MF=(E,(1))
L 1,=V(WTO2)
WTO MF=(E,(1))
RETURN (14,12),T,RC=0
LTORG ,
END EXWTO
The data module
WTODATA CSECT
ENTRY WTO1,WTO2
WTO1 WTO 'FIRST WTO MACRO',MF=L,ROUTCDE=11,DESC=7
WTO2 WTO 'SECOND WTO MACRO',MF=L,ROUTCDE=11,DESC=7
END ,
Sample JCL to assemble, link, and run the modules. The modules are in a PDS in my userid.
//EXWTO EXEC HLASMC
//SYSLIN DD DSN=&&EXWTO
//SYSIN DD DISP=SHR,
// DSN=&SYSUID..LINKMOD.ASM(EXWTO)
//WTODATA EXEC HLASMC
//SYSLIN DD DSN=&&WTODATA
//SYSIN DD DISP=SHR,
// DSN=&SYSUID..LINKMOD.ASM(WTODATA)
//LINK EXEC PGM=IEWL,PARM='MAP,LIST'
//SYSPRINT DD SYSOUT=*
//SYSLMOD DD DISP=(,PASS),UNIT=SYSDA,
// SPACE=(CYL,(1,1,1)),DSN=&&G(G)
//EXWTO DD DISP=(OLD,DELETE),
// DSN=&&EXWTO
//WTODATA DD DISP=(OLD,DELETE),
// DSN=&&WTODATA
//SYSLIN DD *
INCLUDE EXWTO,WTODATA
//RUN EXEC PGM=*.LINK.SYSLMOD
//SYSUDUMP DD SYSOUT=*
JCL like this will work in many installations, but it will almost certainly violate coding standards in most installations.
Notes.
- The "main" program does not prepare a new save area because it does not call any subroutines. WTO is a system service invoked by an SVC instruction. The system code invoked by the SVC instruction preserves your registers in the system; it does not use or require the register save area whose address is in register 13.
- A plain WTO macro (e.g. WTO 'THIS IS A WTO MACRO') prepares a parameter list that includes the message and invokes the system WTO service. The "execute" form of a WTO macro (e.g. WTO MF=(E,PARMLIST) ) load the address of a WTO parameter list and invokes the system WTO service. The "list" form of a WTO macro (e.g., PARMLIST WTO 'THIS IS A WTO MACRO',MF=L prepares the parameter list with a fixed message. A programmer that knows the parameter list can prepare a parameter list with a message containing variable data and use the "execute" form of the WTO macro to write the message.
- The first and second steps overrides the data set name specified in the SYSLIN DD statement in the HLASMC cataloged procedure. The LINK step, which uses the Binder, which does not normally require a SYSUT1 DD statement, and creates load module G in temporary data set &&G. The RUN step executes the load module created by the LINK step. The LINK and RUN steps are typical of RYO (Roll Your Own) JCL.