HP 3000 III Series Manual page 58

Table of Contents

Advertisement

System/CPU Overview
and caused
new additions to the stack as indicated.
Next, Pro-
cedure B called Procedure C and caused the final stack picture as
shown.
As the program progresses, Procedure C will end and, after saving
its answer in a convenient place for Procedure B to access, issue
an EXIT instruction.
Then, all the other stack additions due
to
Procedure C
will
be eliminated
by moving Sand Q back and Pro-
cedure B will
continue its computations on its
own data
stack.
In
the same
manner,
Procedure
B will end, save
its data, and
exit.
This eliminates
the data stack for Procedure B.
Finally,
Procedure A will exit and return the net answer to the new TOS on
th e ma in te mp
0
r a r y s t or a ge are a .
Each time control is
returned from the called
procedure to
the
caller's procedure (w ithin the code segment), the stack registers
also return
to the
caller's data area.
Thus, the stack
marker
chain
virtually eliminates
system overhead in
keeping track of
nested procedures.
For example, the simple return sequence
pre-
viously
discussed
(C-to-B.-to-A-to
rna in p rogr am)
is not impera-
tive.
Procedure C could have been called again before the return
to the main
program was complete or other procedures
could have
been called.
Regardless,
the return for both code and data will
always remain perfectly in step; from the called to the caller.
Note that
the area between DB and First Q in figure 2-11 is
the
global data area.
The locations in this area are reserved by the
process for variables which the process has declared to be global
for all procedures called by that process.
That is,
any
proce-
dure
using
this particular data segment may reference the vari-
ables in this area.
The individual locations in the global
area
can
contain an
actual value or
an indirect address pointing to
some other
location that either" contains
the
value
or is
the
start of an array.
Since DB-relative addressing (paragraph 2-49)
is restricted
to a maximum of DB+255, only the
first
256 loca-
tions
of this
area can be
addressed directly.
These areas are
called the
primary global data area.
If the
number of
entries
exceed 256,
indirect
addressing
(paragraph 2-50) must
be used.
These locations are called the secondary global data area.
When the operating
system has completed assigning space
for the
global variables,
it
points
Q
at the next
succeeding location
(First
Q,
figure
2-11).
This is
the actual
start of the
data
stack.
Since there is not data
on the
stack, S also
points to
this location.
As the executing code segment proceeds to obtain,
manipulate, and generate data for the st&ck, S moves away from
Q,
always indicating the top of such data.
At some time during
the
execution
of the code segment, it is assumed that Procedure A is
called.
Usually, a set of
procedure
parameters
accompany
the
call and
these parameters are
placed on the stack just prior to
the issuance
of the PCAL instruction.
These
are actual
param-
eters
to be
substituted for formal
parameters in the procedure
and are referenced by Q addressing.
(Refer to paragraph 2-49.)
2 -26

Advertisement

Table of Contents
loading

Table of Contents