Previous Topic: Define the OPSLINK Routine in COBOL ProgramsNext Topic: OPSLINK Function Calls


Call OPSLINK from Assembler Programs

The arguments passed to OPSLINK are either text strings or integer values. All text strings passed should be defined in the calling program as follows:

ARGSTR DC H'length',C'text'

The length indicates the number of characters in text. Zero indicates a null string. All integer values are fullword signed binary and should be defined as follows:

ARGWORD DC F'value'

The optional 6th argument of all OPSLINK calls is an output array that should be defined as:

ARRAY  DS 1000CL258

The number 1000 is arbitrary but should be large enough to accommodate the maximum number of output lines expected to be returned by each call. The fifth argument passed to OPSLINK sets the size of the array. The size was set to 1000 in the above example. Each element is 258 bytes long, starting with a halfword-length field, followed by a 256-byte string area.

Assembler programs must turn on the VL bit when calling OPSLINK. The VL bit is the high-order bit in the last word of the parameter list. Also, the calling program must have an AMODE of 31 if a LOAD followed by either a BALR or a BASR is issued.

Before the first call is made to OPSLINK, you must load the subroutine into memory by issuing the LOAD macro instruction. After the last call to OPSLINK, delete the subroutine from memory using the DELETE macro instruction. On return from the LOAD macro, if register 15 is zero, register 0 contains the address of the load module in bits 1-31. Check the appropriate IBM manual for further details on the LOAD and DELETE macros.

The CA OPS/MVS API calling sequence from assembler is as follows:

         LOAD  EP=OPSLINK      Load the subroutine
         LTR   R15,R15
         JNZ   ERROR
         ST    R0,OPSLINKA     Save the subroutine address          .
          .
          .
         OC    PARMLAST(1),=X'80'  Turn on VL bit
         LA    R1,PARMLIST     Parameter list address
         L     R15,OPSLINKA    Load OPSLINK address
         BASR  R14,R15         Call OPSLINK
          .
          .
          .
         DELETE EP=OPSLINK     Delete OPSLINK
ERROR    DS    0H
          .
          .

OPSLINKA DS    A                Address of OPSLINK
*
PARMLIST DS    0A               Parameter list passed to OPSLINK
         DC    A(SUBFUNC)       ARG1
         DC    A(SYSID)         ARG2
         DC    A(SUBSYS)        ARG3
         DC    A(CMDSTR)        ARG4
         DC    A(LINECNT)       ARG5
         DC    A(ARRAY)         ARG6
         DC    A(IMSID)         ARG7
PARMLAST DC    A(MFORM)         ARG8
*
SUBFUNC  DC    H'6',C'OPSTSO'   Issue TSO command
SYSID    DC    H'0',C' '        No system ID
SUBSYS   DC    H'0',C' '        No OPS/MVS subsystem name
CMDSTR   DC    H'5',C'LISTC'    TSO command
IMSID    DC    H'0',C' '        No IMSID
MFORM    DC    H'1',C'M'        MFORM(M)
LINECNT  DC    F'100'           Allow for 100 lines
ARRAY    DS    H,CL256          Room for 1 Line
         DS    99CL258          Room for 99 more lines

OPSLINK returns a return code in register 15. Return codes from OPSLINK and their meaning are explained at the end of this section.