Runtime Environments-2-37
Runtime Environments-2-37
intermediate code
semantic analyzer
generator
rdArr() qsort(1,9)
global
main() variable main()
integer 𝑎[11] integer 𝑎[11]
main main
rdArr()
rdArr
integer 𝑖 local
variable
main
rdArr() qsort(1,9)
integer 𝑚, 𝑛
qsort(1,9)
integer 𝑖 local
variable
naming, allocation of
resources, addressability, postreturn
epilogue
and protection
epilogue
Control link
Caller’s responsibility
Links and saved status
responsibility
Control link
Links and saved status
Caller’s
top_stack
Temporaries and local data
Call sequence
• Caller evaluates the actual parameters
• Caller stores a return address and the old value of top_stack into
the callee's activation record
• Caller then increments top_stack past the caller's local data and
temporaries and the callee's parameters and status fields
• Callee saves the register values and other status information
• Callee initializes its local data and begins execution
Return Sequence
• Callee places the return value next to the parameters
• Callee restores top_stack and other registers
• Callee branches to the return address that the caller placed in the
status field
• Caller copies return value into its activation record