HPlogo PA-RISC Procedure Calling Conventions Reference Manual > Chapter 4 The Actual Call

4.1 Control Flow of a Standard Procedure Call

MPE documents

Complete PDF
Table of Contents

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:
  1. In the calling procedure, complete all modifications to variables that may be used by the procedure about to be called.

  2. 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.

  3. Branch to the callee using a BL instruction with RP as the target (link) register.

  4. 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.

  5. Complete execution of the body of the procedure.

  6. Before exiting, restore RP, restore callee-saves registers, and deallocate local frame.

  7. Branch back to the caller using a BV instruction.

  8. Upon return to the caller, store the function result and restore caller-saves registers as necessary.

  9. Continue execution.

Figure 4-1 Control Flow of a Standard Procedure Call

[Figure 4-1]




Chapter 4 The Actual Call


4.2 Efficiency