To associate these three space pointers with the parameters being passed to the
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 name for
any object data element. For a definition of what constitutes a valid name, see
“Name” in the “Program Syntax” topic of the Create Program (QPRCRTPG) API in
the

System API Reference

.
Now that the program has established addressability (the space pointers) to the
three parameters, the program needs to declare how to map (or view) the storage
addressed. The following declarations define the storage addressed (the BAS
argument) by the three space pointer parameters as being packed-decimal (PKD)
scalar data objects (DD) with 15 digits, 5 digits being to the right of the decimal
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 ease of
reading, are similar to the basing space pointers ARG1@, ARG2@, and
RESULT@. The declarations of packed 15,5 are used for consistency with CL.
The declared type and size could be of any other valid type and size. The true
requirement is that the calling program and the MI program agree on the type and
size.
Starting the Instruction Stream
With all the needed declarations now done, the instruction stream definition, where
the program will compare the numeric values (CMPNV instruction) of parameters
one and two, is started:
CMPNV(B) ARG1,ARG2 / LO(ITS2);
The program then branches (the (B) extender to CMPNV) to label ITS2 if ARG1 is
less than ARG2 (the /LO branch target).
Note: MI instructions such as CMPNV are defined in the

Machine Interface Func-

tional Reference

. Pervasive instruction extenders such as branch (B) and
target keywords (LO, HI, EQ, and so on) are defined in the

System API

Reference
under “Instruction Statement,” which is a subheading in the
“Program Syntax” topic of the Create Program (QPRCRTPG) API.
If ARG1 is not low (LO) when compared to ARG2, the next MI instruction in the
source stream is run. When the next MI instruction is run, it copies the numeric
value (CPYNV instruction) of ARG1 to RESULT and, following that, branches to
label RETURN:
CPYNV RESULT,ARG1;
B RETURN;
If ARG2 was greater than ARG1, the CPYNV instruction at label ITS2 is run, setting
RESULT to the value of ARG2:
Chapter 7. Machine Interface Programming 7-3