3. PROCEDURE CALLS
Important frequency used programming construct.
Generate good code for procedural call and return
run-time routines.
Programmatic subroutine(function,procedure, or
subprogram) or sequence of code wich performs a
specific task as part of a larger program that is
grouped as one or more statement blocks with the
typical intention of doing one thing well.
4. Run-time routines it is handle Procedure argument
passing, Calls, and Returns are part of the run-time
support package
Grammar for simple procedure call statement
Scall id(Elist)
ElistElist,E
ElistE
5. CALLING SEQUENCE
Calling sequence is differ, even for implementation
for same language.
Is the code sequence required to effect transfer of
control to a subroutine or procedure, include
parameter passing and recording of the return
address.
6. It is required to call procedures written in a different
language from the calling program.
The difference in procedure calls
i. Source Language.
ii. Target Machine.
iii. Operating System
7. EXAMPLE
Scall id (Elist)
{ for each item p on queue do
emit(‘param’ p)
emit(‘call’ id.place)
}
ElistElist,E
{
Append E.place to the end of queue
}
8. ElistE
{
initialize queue to contain only E.place
}
Scall id(Elist) will generate a param statement for
each item on queue,causing these statements to
follow the statement evaluating the argument
expression.
9. Those statements were generated when the
arguments themseives were reduced to E.
The code for S is the code for Elist, which evaluates
the arguments, followed by a param p statement for
each argument.
Followed by a call statement. A count of the number
of parameters is not generated with the call
statement but could but calculated in the same way
we computed Elist.ndim in the previous section.