Returning To a Program

Use the CMSRET macro to return to the caller from a program that was invoked by SVC 202, or CMSCALL. CMSRET should not be used in user defined exits or immediate commands because CMS transfers control to exits and immediate commands differently than for command invoked modules.

Consider a nucleus extension called PROG1 set up as an immediate command and you interrupt an exec with it. The immediate command exit is not considered to be a new SVC level, so if you issue a CMSRET rather than a BR 14 from PROG1, you cause the current SVC level to be removed. Because of this, the exec is terminated, along with the immediate command, since the exec was the last thing on the SSAVE chain; that is, CMS acts as though the CMSRET was from the exec.

If you have a nucleus extension that can be invoked as both a command and an immediate command, use just the BR 14, or dual path the code to test how you were entered, and proceed accordingly:
         .
         .
         .
         TM    USECTYP,EPLFIMMD      Entered as an Immediate Command?
         BZ    RETOUT                No, CMSRET is safe
         LM    R0,R14,0(R13)         Restore Caller's Registers
         BR    R14                   and return to IMMCMD caller
         SPACE 1
RETOUT   EQU   *                     Invoked as a nucleus extension
         CMSRET                      Return to command caller
This applies to:
  • Immediate commands
  • HNDIO
  • HNDEXT
  • HNDSVC
  • HNDIUCV
  • ABNEXIT.

The rule of thumb is if it is an EXIT, do not invoke CMSRET.