Hardware Reference
In-Depth Information
A
Calling
procedure
B
Called
procedure
A called
from main
program
A returns
to main
program
Figure 5-41.
When a procedure is called, execution of the procedure always be-
gins at the first statement of the procedure.
main program but that is irrelevant.) Furthermore, first control is transferred from
A
to
B
—the call—and later control is transferred from
B
to
A
—the return.
The asymmetry arises from the fact that when control passes from
A
to
B
, pro-
cedure
B
begins executing at the beginning; when
B
returns to
A
, execution starts
not at the beginning of
A
but at the statement following the call. If
A
runs for a
while and calls
B
again, execution starts at the beginning of
B
again, not at the
statement following the previous return. If, in the course of running,
A
calls
B
many times,
B
starts at the beginning all over again each and every time, whereas
A
never starts over again. It just keeps going forward.