Code generation for function call

Code generation for function code is base on the runtime storage. The runtime storage can by static allocation or stack allocation. In case of static allocation the position of activation record in memory is fixed at the compile time. To recollect about activation record, whenever a function is called, activation records are generated, these records store the parameters to be passed to functions, local data, temporaries, results & some machine status information along with the return address. In case of stack allocation, every time a function is called, the new activation record in generated & is pushed onto stack, once the function completes, the activation record is popped from stack. The three address code for function call consists of following statements

1. Call.
2. Return
3. end
4. action
Call statement is used for function Call, it has to mail the control to the function along with saving the status of current function.


 Return statement is used to give the control back to called function. Action defines other operations or instructions for assignment or flow control statements. End indicates the completion of operations of called function.

0 comments