Machine  Instruction                                                                                                                                   Print this page
<< Previous |  First Last |  Next >>       

Procedure Call Instruction

A procedure is a self contained computer program that is incorporated into a large program. At any point in the program the procedure may be invoked, or called. The processor is instructed to go and execute the entire procedure and then return to the point from which the call took place.
The procedure mechanism involves two basic instructions: a call instruction that branches from the present location to the procedure, and a return instruction that returns from the procedure to the place from which it was called. Both of these are forms of branching instructions.
Some important points regarding procedure call:

    • A procedure can be called from more than one location.
    • A procedure call can appear in a procedure. This allows the nesting of procedures to an arbitrary depth.
    • Each procedure call is matched by a return in the called program.

Since we can call a procedure from a variety of points, the CPU must somehow save the return address so that the return can take place appropriately. There are three common places for storing the return address:

  • Register
  • Start of procedure
  • Top of stack
<< Previous |  First |  Last |  Next >>