Declaring Pointers

The next statements declare a system

pointer named

USRSPCOBJ

and a

s

pointer named USRSPC. USRSPCOBJ contains

the address of the *USRSPC

 

object after the execution of the

RSLVSP

instruction

later in

the

in

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

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

sys

pointer

CL05

to

the

name of

the

PGM

CL05. The

CL05

pointer

is not

set

to

address

of

the

CL05

 

object—this

happens

the

first

time

the

CL05 point

to in the instruction stream. If youSystemreviewAPI

Referencethe for

this

 

 

 

declare

 

statement,

 

notice that the

context

(CTX) argument

uses

the

d

the context default (better known as library to most programmers) is

 

specifying *LIBL. *LIBL is referred to as the process

 

name

resolutio

Machine Interface Functional Reference.

 

 

 

 

 

 

 

 

 

Because

 

this

program

calls

the CL05 program (CALLX CL05)

with

parameters,

now

defines

an

operand list

CL05OL, which

specifies

the

arguments

to

b

on

the

CALLX:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

DCL OL CLð5OL (MBR@, USRSPC, BINOFFSET@) ARG;

 

 

 

 

 

 

 

 

 

 

When

you

get

to

the

instruction

stream

of

MICRTPG,

copy

the

passed

 

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-ju

with

pad

(CPYBLAP)

instruction

to

set

the

rightmost

20

bytes

of

RSLVNAME

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'02 'of andX a

subtype'01'ofto X resolve

a

system

pointer

to

the CL05 *PGM object. The two

different

approaches

were

used

to

strate

the different

styles

(RSLVSP is

clearly

more

flexible)

a

within the 2000-byte limit of

the

program source

size

imposed

b

CLCRTPG

program.

 

 

 

 

 

 

 

 

 

 

Then set the USRSPC space pointer to the first byte of the *USRSPC:

SETSPPFP USRSPC, USRSPCOBJ;

Chapter 7. Machine Interface Programming7-17

Page 157
Image 157
IBM Version 4 manual Declaring Pointers, Usrspcobj