IBM OS/390 User Manual

Page of 673
13.2.1.1 Initiation
Under VSE, main programs (those programs that are invoked by the operating
system directly) are not required to save any registers upon entry. VSE assembly
programs are not required to provide a save area unless that program invokes
(calls) another program. In MVS, all programs are executed as subroutines
including the program that is given control by the operating system. Therefore,
all programs that are changed to MVS must ensure the presence of an
initialization routine meeting MVS requirements. This initialization routine must
do the following:
Store all registers, except register 13, in the system or calling program save
area (STM 14,12,12(13))
Establish a base register - it must not be register 13 - to point to the start of
this program.
Provide a new save area in this program.
Store the address of the calling (may be MVS) program
s save area in the
called program
s save area (R13 + 4 - backward chain)
Set up register 13 to point to this program
s save area if this program is to
call subsequent subroutines or issue any system macros.
Store register 13 in the calling program
s save area + 8 (forward chain)
This routine can be standard code established for the entire installation; it can
then easily be inserted in the front of each program.
Note:
Register 13 should not be used for any function other than pointing to a
save area. For more information, refer to Figure 27 on page 270 and Figure 28
on page 271 for examples of this routine.
13.2.1.2 Termination
At job termination, VSE uses the EOJ macro which generates a supervisor call.
The VSE supervisor, which maintains control of its own registers, then branches
to the appropriate routine. Because this macro facility is not available under
MVS you must return to the control program at the end of job as follows:
 1. Restore the control program
s registers to their status upon entering this
routine.
 2. Branch to the return address stored in register 14.
You may also accomplish this function by using the MVS 
RETURN
″ 
macro. The
RETURN macro requires that Register 13 contains the address of the save area
in the program that you are returning to.
Register Conventions
MVS linkage register conventions, upon entry to a routine, are compatible to
those of VSE:
Reg. 13
Points to the calling program
s save area.
Reg. 14
Points to the return address in the calling program.
Reg. 15
Points to the entry point of this called program.
Reg. 0 and 1
Points to parameters or lists of parameters passed from the calling
program to this called program.
Chapter 13. A s s e m b l e r
269