LOADCMD

Format

Read syntax diagramSkip visual syntax diagramLOADCmd name member

Purpose

Use the LOADCMD command to define a program module to be executed as a command.

LOADCMD is a feature that lets you define your own commands; it lets you assign a command name to a program module. (The module for this program must reside in a CMS load library that you have defined with a GLOBAL command.) When you enter the command name, this module gets control and executes. It remains in storage, waiting to be run again when you enter its assigned name from either the console or the CMDSI macro or a command file (EXEC).

For example, to run the GCS application ACF/VTAM, you first have to define the VTAM command. VTAM is a command name that will be processed by one of ACF/VTAM's program modules. After you have defined and issued this VTAM command name, you can enter any of the following ACF/VTAM commands:
  • START
  • HALT
  • VARY
  • MODIFY
  • DISPLAY

Operands

name
The name of the command you are defining.
member
The member of a CMS load library associated with the command you have defined. This member is the module that executes the command you have defined; it is loaded into private, free storage.

When you enter the name, GCS calls the member to run the command. Here's what your registers will contain:

Register Contents
0 Address of an extended parameter list.
1 Address of a tokenized parameter list of consecutive doublewords. The first item in the list is the name of your called routine or program. Other items in the list may contain arguments you want passed to it.
3 Address of a word (UWORD) in storage that is available for the command's use.
12 Address of the entry point to your program. You can use this address as a base address to establish immediate addressability in your program.
13 Address of a 96-byte save area for your program's use.
14 Return address of the SVC handling routines. The program returns control to this address after it finishes executing.
15 Same as Register 12, except that you should not use this one as a base register. The SVCs use it to communicate with the program, and GCS uses it to return a completion code. Any time that completion code is nonzero, you will see it in the ready message (if you entered the command at the console):
Ready(nnnnn);
If the program you run does not return a completion code in Register 15, make sure it puts a zero there before transferring control. Otherwise, your ready message may contain meaningless data (whatever was in Register 15 at the time).

When you enter a command, a GCS scan routine sets up two distinct parameter lists:

  • The first list is a tokenized parameter list. (Register 1 contains its address.) The parameters listed there line up on consecutive doubleword boundaries. Blanks and parentheses serve as delimiters separating each parameter. (Parentheses show up in the list, each on a doubleword boundary.)
  • The second is an extended, or not tokenized, parameter list. (Register 0 contains its address.) It contains addresses that map out the extended form of a command. This extended parameter list has the following format:
    EPLMAP DC  A(CMDBEG)  ADDR OF COMMAND TOKEN
           DC  A(ARGBEG)  ADDR OF BEGINNING OF ARGUMENTS
           DC  A(ARGEND)  ADDR OF END OF ARGUMENTS
           DC  A(0)       ADDR OF EXEC FILEBLOCK
           DC  A(0)       ADDR OF FUNCTION ARGUMENT LIST
           DC  A(0)       ADDR FOR RETURN OF FUNCTION DATA
           DS  X          INDICATOR (see the following note)
           DS  3X         RESERVED
    Note: An INDICATOR byte of X'00' is a sign that a program issued the command. X'0B' is a sign that it was issued from the console. X'01' is a call from REXX when ADDRESS COMMAND is specified. X'05' is used by REXX for function calls.

Here are two ways you might enter a command and two sets of accompanying tokenized and extended parameter lists that result:

  1. You enter:
       ====> loadcmd cmdname memname
    The scan routine sets up the following tokenized parameter list:
    FORMAT:  DC   CL8'LOADCMD'
             DC   CL8'CMDNAME'
             DC   CL8'MEMNAME'
             DC   8X'FF'
    The scan routine sets up the extended parameter list with the following references:
    CMDBEG  DC   C'loadcmd'
    ARGBEG  DC   C'cmdname memname'
    ARGEND  EQU  *
    The first nonblank character following ‘loadcmd’ determines the start of ARGBEG.

    Note: The tokenized parameter list is passed with uppercase characters. The extended parameter list is passed with mixed case (as entered) characters.

  2. You enter ‘loadcmd’ without specifying any arguments:
    ====> loadcmd
    The scan routine sets up the following tokenized parameter list:
    FORMAT:  DC   CL8'LOADCMD'
             DC   8X'FF'
    The scan routine sets up the extended parameter list with the following references:
    CMDBEG  DC   C'loadcmd'
    ARGBEG  EQU  *
    ARGEND  EQU  *
    With no arguments specified, ARGBEG is set equal to ARGEND.

    Note: The tokenized parameter list is passed with uppercase characters. The extended parameter list is passed with mixed case (as entered) characters.

For more information on parameter lists, see z/VM: CMS User's Guide.

Usage

If the program defined by the LOADCMD is reentrant, then it is loaded into key 0 storage. This ensures that it is not accidentally modified or tampered with.

Examples

LOADCMD MYCMD MYMOD
Defines the command named MYCMD to GCS. The module containing the code for this command can be found in a CMS load library under the member name of MYMOD. Then, by issuing:
MYCMD
The module named MYMOD is invoked.

Messages

  • GCTLDC212E Member cannot be loaded. Command is not defined RC=xx
  • GCTLDC240I No entry points were loaded by the LOADCMD command

For more information on messages, see z/VM: Other Components Messages and Codes.

Return Codes

The meanings of return codes for the GCTLDC212E message are:
Hex
Code
Decimal
Code
Meaning
X'01' 1 The command has already been defined.
X'04' 4 The module is marked not executable. The module is not loaded and the command is not defined. The module is not suitable for use as a command module. Consult the information provided by the linkage editor, at the time the module was created, to determine why the module is not executable.
X'0A' 10 The module is an overlay structure. The module is not loaded and the command is not defined. If this module is to be used as a command module, it must be redefined so that it does not require overlays.
X'0C' 12 The module is marked only loadable. The module is not loaded and the command is not defined. This module is not suitable for use as a command module.
X'0E' 14 The command name specified is a GCS immediate command or an abbreviation for one.
X'18' 24 Too many operands were specified.
X'1C' 28 The specified member cannot be found.
X'20' 32 No member name was specified.
X'24' 36 A permanent I/O error was found when the system attempted to search the CMS LOADLIB directory.
X'28' 40 Insufficient virtual storage was available to read the directory entry for this module.
X'29' 41 Insufficient free storage was available to build the nucleus extension control blocks representing this command.