Declaring Pointers
The next statements declare a system pointer named USRSPCOBJ and a space
pointer named USRSPC. USRSPCOBJ contains the address of the *USRSPC
object after the execution of the RSLVSP instruction later in the instruction stream.
USRSPC addresses the first byte of the *USRSPC:
DCL SYSPTR USRSPCOBJ;
DCL SPCPTR USRSPC;
Defining an External Call
Because this program also uses the call external (CALLX) instruction to call the CL
program CL05, define a system pointer for CL05:
DCL SYSPTR CLð5 INIT("CLð5", TYPE(PGM));
The preceding statement causes the QPRCRTPG API to initialize the system
pointer CL05 to the name of the PGM CL05. The CL05 pointer is not set to the
address of the CL05 object—this happens the first time the CL05 pointer is referred
to in the instruction stream. If you review the
System API Reference
for this
declare statement, notice that the context (CTX) argument uses the default. Using
the context default (better known as library to most programmers) is equivalent to
specifying *LIBL. *LIBL is referred to as the process name resolution list in the
Machine Interface Functional Reference
.
Because this program calls the CL05 program (CALLX CL05) with parameters, it
now defines an operand list CL05OL, which specifies the arguments to be passed
on the CALLX:
DCL OL CLð5OL (MBR@, USRSPC, BINOFFSET@) ARG;
When you get to the instruction stream of MICRTPG, copy the passed parameter
MBR to the data structure element RSLVNAME. As RSLVNAME is defined as
CHAR(30) and MBR is CHAR(10), the program uses the copy bytes left-justified
with pad (CPYBLAP) instruction to set the rightmost 20 bytes of RSLVNAME to the
value of the third argument (in this case, blanks):
CPYBLAP RSLVNAME, MBR, ' ';
Having established the *USRSPC name, use the RSLVSP instruction to get
addressability to the object itself:
RSLVSP USRSPCOBJ, RSLVOBJ, \, \;
Note: Similar to how the *USRSPC name was resolved, RSLVSP could be used
with a type of X'02' and a subtype of X'01' to resolve a system pointer to
the CL05 *PGM object. The two different approaches were used to demon-
strate the different styles (RSLVSP is clearly more flexible) and also to stay
within the 2000-byte limit of the program source size imposed by the
CLCRTPG program.
Then set the USRSPC space pointer to the first byte of the *USRSPC:
SETSPPFP USRSPC, USRSPCOBJ;
Chapter 7. Machine Interface Programming 7-17