Requirements for compiled-language exit routines

You must issue a SET EXITEXEC command before setting the CMPEXIT option so that IDF knows the name of the exit routine.

z/VM®
Your compiled-language exit routine must be a NUCXLOADable CMS MODULE.

When the SET CMPEXIT ON command is issued, IDF will NUCXLOAD the exit routine.

IDF never invokes the NUCXLOADed exit routine by means of SVC-202. It obtains the entrypoint address from the SCBLOCK associated with the exit routine after it is NUCXLOADed, and invokes it with BALR.

z/OS®
When the SET CMPEXIT ON command is issued, IDF will load the exit with a LOAD SVC. IDF calls the exit with a BALR after having obtained its address from the LOAD of the exit.
z/VSE®
When the SET CMPEXIT ON command is issued, IDF will load the exit with CDLOAD. IDF calls the exit with a BALR after having obtained its address from the CDLOAD of the exit.

The compiled-language exit routine can be written in the language of your choice, so long as it is able to conform to the calling sequence used by IDF. The interface used is designed for PL/I-like exit routines, but an assembler routine can also be used.

At entry to the exit routine, R1 points to a fixed length parameter list:
Figure 1. Parameter list passed to compiled-code exit routine
* parameter list passed to compiled-code exit routine
         DC      A(calltype)        address of call-type (fullword)
         DC      V(subcom)          address of subcommand interface
         DC      A(psw)             address of current PSW
         DC      A(gpr)             address of current GPRs
         DC      A(varname)         address of variable name
         DC      A(varnamel)        address of variable name length
         DS      A(varval)          address of variable value
         DC      A(varvaln)         address of variable value length
         DS      A(pstring)         address of pstring
         DC      A(pstringl)        address of pstring length

The first parameter is the call-type. The exit routine is invoked on event occurrence, and if it issues any EXTRACT commands during its processing, it is re-entered (recursively) to receive the values normally set into REXX variables. A call-type of 0 (zero) indicates an EVENT invocation. A call-type of 4 indicates a VARIABLE invocation.

The exit routine, when entered, must inspect the call-type as its first order of business. It will not be re-entered unless is issues EXTRACT commands to the IDF command processor, but if it is re-entered the call-type value will have changed to 4, indicating a VARIABLE invocation.

The remaining parameters are either invariant, or apply to only one type of call.

All of the parameters passed and their meanings are:
  1. Address of call-type: The call-type is contained in a fullword. A value of 0 (zero) indicates an EVENT call, and a value of 4 indicates a VARIABLE call.
  2. Address of subcommand interface: This address is the start of the IDF subcommand processor. The exit routine may call the subcommand processor to execute IDF commands. It must enter the subcommand processor with R1 containing the address of a parameter list as follows:
             DC    A(CSTRING)
             DC    A(CSTRINGL)
             ...
    CSTRING  DC    C'whatever command string'
    CSTRINGL DC    A(L'CSTRING)
    If an EXTRACT command is issued, the exit routine must be prepared to receive the variables extracted. It will therefore be recursively re-entered and the call-type will indicate a VARIABLE call.
  3. Address of current PSW: This word points to the target program's current PSW.
  4. Address of current GPRs: This word points to the target program's current GPRs.
  5. Address of variable name: (Applicable only when call-type is 4.) This word points to the start of a character string which is the name of the extracted variable.
  6. Address of variable name length: (Applicable only when call-type is 4.) This word points to a fullword containing the length of the variable name in bytes.
  7. Address of variable value: (Applicable only when call-type is 4.) This word points to a character string which represents the current value of the extracted variable.
  8. Address of variable value length: (Applicable only when call-type is 4.) This word points to a fullword containing the length of the current value of the extracted variable in bytes.
  9. Address of pstring: (Applicable only when call-type is 0.) This word points to the start of a character string describing the event causing the exit routine's invocation. The contents of the character string are described in The IDF exit routine.
  10. Address of pstring length: (Applicable only when call-type is 0.) This word points to a fullword which contains the number of bytes in the parameter string which describes the event causing the exit routine's invocation.