The main program and first argument: the operation code

The arguments to the exit follow standard 390 level two coding conventions: a pointer is provided to each argument.

The sample COBOL exit takes advantage of the fact that COBOL expects each argument to be a pointer. COBOL internally sets the address of the associated 01 structure in the LINKAGE SECTION.

The first argument in every call to the exit is a pointer to an operation code:

01 RAM-OPCODE PIC S9(9) BINARY.
01 RAM-OPCODE-VAL REDEFINES RAM-OPCODE PIC X(4).
88 OPCODE-INIT-RAM           VALUE X"09010000".
88 OPCODE-TERM-RAM           VALUE X"09010001".
88 OPCODE-VALIDATE-REPOS     VALUE X"09010004".
88 OPCODE-GET-1ST-MEM-REC    VALUE X"09010014".
88 OPCODE-GET-NEXT-MEM-REC   VALUE X"09010015".
88 OPCODE-GET-1ST-MEM-INFO   VALUE X"09010010".
88 OPCODE-GET-NEXT-MEM-INFO  VALUE X"09010011".
88 OPCODE-GET-DISPLAY-INFO   VALUE X"09010008".

The calls defined as level 88s in the COBOL code are the services which FMNCRAEX must provide.

Here is the main program showing how the OpCode is received by the FMNCRAEX program:

PROCEDURE DIVISION USING RAM-OPCODE,
                         RAM-WORK-AREA-PTR,
                         RAM-PARM2,
                         RAM-PARM3,
                         RAM-PARM4,
                         RAM-PARM5,
                         RAM-PARM6.
MAIN SECTION.

STARTUP-RAM.
    IF TRACELVL >= TRACEBAS THEN PERFORM TRACE-STARTUP.
    MOVE 0 TO RAM-RC.

SELECT-RAM-FUNCTION.
    EVALUATE TRUE
       WHEN OPCODE-INIT-RAM
          PERFORM INIT-RAM
       WHEN OPCODE-TERM-RAM
          PERFORM TERM-RAM
       WHEN OPCODE-VALIDATE-REPOS
          PERFORM VALIDATE-REPOS
       WHEN OPCODE-GET-1ST-MEM-REC
          PERFORM GET-1ST-MEM-REC
       WHEN OPCODE-GET-NEXT-MEM-REC
          PERFORM GET-NEXT-MEM-REC
       WHEN OPCODE-GET-1ST-MEM-INFO
          PERFORM GET-1ST-MEM-INFO
       WHEN OPCODE-GET-NEXT-MEM-INFO
          PERFORM GET-NEXT-MEM-INFO
       WHEN OPCODE-GET-DISPLAY-INFO
          PERFORM GET-DISPLAY-INFO
       WHEN OTHER
          SET RAM-RC-UNKNOWN-OPCODE TO TRUE
    END-EVALUATE.

RETURN-FROM-RAM.
    MOVE RAM-RC TO RETURN-CODE.
    GOBACK.