Javatpoint Logo
Javatpoint Logo

Procedures call

Procedure is an important and frequently used programming construct for a compiler. It is used to generate good code for procedure calls and returns.

Calling sequence:

The translation for a call includes a sequence of actions taken on entry and exit from each procedure. Following actions take place in a calling sequence:

  • When a procedure call occurs then space is allocated for activation record.
  • Evaluate the argument of the called procedure.
  • Establish the environment pointers to enable the called procedure to access data in enclosing blocks.
  • Save the state of the calling procedure so that it can resume execution after the call.
  • Also save the return address. It is the address of the location to which the called routine must transfer after it is finished.
  • Finally generate a jump to the beginning of the code for the called procedure.

Let us consider a grammar for a simple procedure call statement

A suitable transition scheme for procedure call would be:

Production Rule Semantic Action
S → call id(Elist) for each item p on QUEUE do
  GEN (param p)
    GEN (call id.PLACE)
Elist → Elist, E append E.PLACE to the end of QUEUE
Elist → E initialize QUEUE to contain only
   E.PLACE

Queue is used to store the list of parameters in the procedure call.


Next Topicdeclarations




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA