HP 3000 III Series Manual page 171

Table of Contents

Advertisement

Machine Instructions and Stack Operations
6 is the procedure statement which is the executable part of
the
procedure
body.
This is the statement that will cause the divi-
sion of
J
by K and temporarily store the quotient as a
procedure
result,
identified
by the procedure name QUOTIENT.
The call to
the procedure is given at line 8.
This is an
executable
state~
ment as opposed to a procedure declaration.
When this statement
is encountered in the program,
it
causes
the
procedute
named
QUOTIENT to be executed, passing actual parameter of 25 and 10 to
the procedure,
and causes the global variable
ANSWER
to assume
the value of the result.
This completes the program.
Lines 10 through 19 show the
machine language code that the com-
piler emits
for
the
two
executable statements in
the program
(i .e., line 6 causes line 10 through 14 to be generated and
line
8 Causes
lines 15 through 19 to be generated).
In order
to ex-
plain the
operation of
the program in
machine language,
it is
necessary
to examine what is
happening on the stack.
It is as-
sumed that the user has logged onto the system,
has compiled the
program,
and is ready to run
(or is running a program that will
shortly encounter the statement in line 8).
Loading the
program
causes space
to be allocated
for the one
global variable,
AN-
SWER, which is at DB+O as shown in (A), figure 4-17.
Since there
are no other global variables, Q and S
initially
point
at
the
immediately
following
location.
(The
content of that location
will never be signifiant; in essence it is a dummy Delta Q
loca-
tion.) Additionally, during program loading, the operating system
evaluates the program in order to set the Z Iegister appropriate-
ly for an initial estimated stack size.
Also, since
no
dynamic
arrays
are
declared, DL is set coincident with DB, therefore DL
is not shown. (Refer to paragraph 2-28.)
It is assumed that the user has issued a system command
to
exe-
cute
the
procedure
carl
given in line 8 of figure 4-16.
This
causes control to be passed to line 15 in
the
machine
language
program
where
the
sequence
to call the procedure begins.
The
first instruction is a ZERO,NOP.
Executing this instruction puts
a "0" on the stack and
increments
the
S-pointer,
(A),
figure
4-17.
This reserves a location for the procedure result.
Next
at (B) and (C)
(lines 16 and 17), the parameter values 31 and
12
are passed directly from the instruction words to the stack (area
reserved for procedure parameters).
Octal notation is
used
for
these
values.
Then at (D), a procedure call instruction (PCAL)
causes a four-word stack marker to be placed on the stack.
The
S- and Q-pointers point to the Delta
Q
location
of
the
marker
which
now
indicates 7 (the number of locations back to the ini-
tial
Q
location).
It is assumed that entry number 20 in the Seg-
ment Transfer Table will direct the call to the correct procedure
starting point. (Refer to paragraph 2-24.)
Execution of the
procedure now begins (line 10) •
The first two
instructions
(lines 10 and 11) load copies of the procedure par-
ameters onto
the TOS (E)
and (F),
using Q-relative addressing.
The next instruction (line 12) divides the top-of-stack parameter
into the next-to- top
parameter and substitutes the
quotient "2"
and the remainder
"5"
on the TOS
as shown at (G).
The second
4-41

Advertisement

Table of Contents
loading

Table of Contents