To associate these three space pointers with the

parameters

being

program, the

following

operand

list

(OL)

is

declared:

 

 

 

DCL

OL

 

PARM_LIST

/\ Name of OL is PARM_LIST

\/

 

 

 

 

 

(ARG1@,

 

/\ The first parameter

\/

 

 

 

 

 

ARG2@,

 

/\ The second parameter

\/

 

 

 

 

 

RESULT@)

/\ The third parameter

\/

 

 

 

 

 

PARM

EXT;

/\ External parameter list

\/

 

 

The

names

ARG1@, ARG2@,

RESULT@,

and PARM_LIST are chosen by

you

 

and

are

not

mandated

by the

AS/400 system. You

can

choose

any

valid

any object data element. For

a definition

of

what

constitutes

a vali

“Name” in the “Program Syntax”

topic

of

the

Create

Program

(QPRCRTPG) AP

the System

API Reference.

 

 

 

 

 

 

 

 

Now that the program has established addressability (the space poin three parameters, the program needs to declare how to map (or vie addressed. The following declarations define the storage addressed argument) by the three space pointer parameters as being packed-dec scalar data objects (DD) with 15 digits, 5 digits being to the rig point:

DCL

DD

ARG1

PKD(15,5)

BAS(ARG1@);

DCL

DD

ARG2

PKD(15,5)

BAS(ARG2@);

DCL

DD

RESULT

PKD(15,5)

BAS(RESULT@);

The names ARG1, ARG2, and RESULT are chosen arbitrarily, but, for ea reading, are similar to the basing space pointers ARG1@, ARG2@, and RESULT@. The declarations of packed 15,5 are used for consistency wit The declared type and size could be of any other valid type and requirement is that the calling program and the MI program agree on size.

Starting the Instruction

Stream

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

With

all the needed declarations now done, the

instruction

stream de

the

program

will

compare

the numeric

values

(CMPNV

instruction)

 

of

parame

one and

two,

is

started:

 

 

 

 

 

 

 

 

 

 

 

CMPNV(B)

 

ARG1,ARG2

/ LO(ITS2);

 

 

 

 

 

 

 

 

The

program

then

branches

(the

(B)

extender

to

CMPNV)

to label

ITS2

less

than ARG2

(the

/LO

branch

target).

 

 

 

 

 

 

 

Note:

MI

instructions

such

 

as CMPNV are definedMachine

Interfacethe

Func-

 

tional Reference. Pervasive instruction extenders such as branch (B)

 

target keywords (LO, HI, EQ, and so on) areSystemdefinedAPI in the

 

Referenceunder “Instruction Statement,” which is a subheading in

 

“Program

Syntax”

topic

of

the

Create

Program

(QPRCRTPG)

API.

 

If

ARG1 is not low (LO)

 

when

compared to

ARG2,

the

next

MI

instruc

source stream is run. When

the next MI instruction is

run,

it

copies

value

(CPYNV

instruction) of

ARG1

to

RESULT

and,

following

that,

branches

label

RETURN:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CPYNV RESULT,ARG1;

BRETURN;

If ARG2 was greater than ARG1, the CPYNV instruction at label ITS2 RESULT to the value of ARG2:

Chapter 7. Machine Interface Programming7-3

Page 143
Image 143
IBM Version 4 manual ITS2, ARG2, Cpynv, Result