|
|
Figure 4-1 shows the progression of a standard procedure call. To read the
diagram, begin at "Calling Code" and continue downward, following any arrows
that may extend from the end of a line.
To summarize, the steps involved are:
In the calling procedure, complete all modifications to variables
that may be used by the procedure about to be called.
Before the call, place all actual arguments onto the stack or into
argument registers. As necessary, save any values being held in
caller-saves registers to memory.
Branch to the callee using a BL instruction with RP
as the target (link) register.
Upon entry, save RP in the caller's frame marker (if this
is a non-leaf procedure). Allocate the local frame by incrementing
the stack pointer, and save any callee-saves registers that will be
used.
Complete execution of the body of the procedure.
Before exiting, restore RP, restore callee-saves registers,
and deallocate local frame.
Branch back to the caller using a BV instruction.
Upon return to the caller, store the function result and restore
caller-saves registers as necessary.
Continue execution.
Figure 4-1 Control Flow of a Standard Procedure Call
|