Implement Subprograms Flashcards
Subroutine linkage
Subroutine call and return operations
Implementation of subroutines must be based on ….
Semantics of the subroutine linkage
Semantics of a subroutine call (4)
(1) save the execution status of the current Program unit
(2) pass the Parameters
(3) pass the return address to the callee
(4) transfer control to the callee
Subroutine return:
If there are pass-by-value-result or out-mode parameters, the current values of those parameters are move to …
The corresponding actual parameters
Subroutine return:
Move the return value to…
A place accessible to the caller
Subroutine return:
Execution status of the caller is …
Returned
Subroutine return:
Control is transferred …
Back to the caller
Storage:
Call and return actions require storage for … (5)
Status information about the caller, parameters, return address, return value for functions, and local variables
“Simple” subroutines are
Those that cannot be nested and all local variables are static.
A simple subroutine consists of two parts: (give def for each to/size)
Code and data
Code: constant (instruction space)
Data: can change when the subroutine is executed (data space)
Both have fixed size
Activation record is
The format or layout of the data part because the data is relevant to an activation, execution, of the subroutine
The formation of an activation record is
Static
An activation record instance is a
Concrete example of an activation record corresponding to one execution
An activation record for a simple subroutine
What does the stack look like, size, allocation type, side note
Local var
Params
Return Add
Fixed size (statically allocated)
Could be attached to the code part of the sub Program
When each programming unit is compiling is it
Machine code along with a list of references to external sub programs are written to a file
A linker is called for …
MAIN to create an executable program