Contents of registers

The contents of the registers on entry to the callable service are:
Register 0
Address of the secondary parameter block (SPB)
Register 1
Address of the parameter list
Register 2–13
Unpredictable
Register 14
Return address
Register 15
Service entry point address
The contents of the registers on exit from the callable service are:
Register 0
Reason code
Register 1–14
Same as on entry
Register 15
Return code

Figure 1 shows an example of entry and exit code for a generic service.

Figure 1. Example of a service entry and exit
MYSERV    CSECT
MYSERV    AMODE  31
MYSERV    RMODE  ANY
          USING  *,15
          B      PROLOG                Branch around header text
          DC     C'some text'
          DC     C'compile date/time'
PROLOG    EQU    *
          DROP   15
          BSM    R14,0   
          BAKR   14,0                  Save callers info on stack
          LAE    12,0                  Clear access register 12
          LR     12,15                 Load reg 15 into 12
PROGSTRT  EQU    *
          USING  MYSERV,12             Set up base register
*                                       addressability
          .
          .
          .
          Get dynamic area for program
          .. STORAGE OBTAIN or CELLPOOL or own scheme ...
          .
          .
          Free dynamic area for program
          .
          .   
          .
RETURN    L      0,REASON_CODE         Put reason code in reg 0
          L      15,RETURN_CODE        Put return code in reg 15
          PR
 

The example uses the instructions BAKR and PR to replace standard linkage. With these instructions, you no longer need to pass the save area in a register.

If the callable service ends abnormally, ICSF takes a system dump. The ICSF service functional recovery routine (FRR) PROTECTS an installation-defined service. You can, however, write your own recovery routine.