CHAPTER 9

 

IMPLEMENTING SUBPROGRAMS

 

 

THE GENERAL SEMANTICS OF CALLS AND RETURNS

 

 

IMPLEMENTING FORTRAN 77 SUBPROGRAMS

-          Save the execution status of the current program unit

-          Carry out the parameter-passing  process

-          Pass the return address to the callee

-          Transfer control t the callee

-          If pass by value, the current values of those parameters are moved to the corresponding actual parameter.

-          If the subprogram is a function, the functional value is moved to a place accessible to the caller.

-          The execution status of the caller is restored.

-          Control is transferred back to the caller.

 

-          status information about the caller

-          parameters

-          return address

-          functional value for function subprograms

 

 

Fortran 77 activation record

Functional value

Local variables

Parameters

Return address

 

 

-          parameters can usually be passed by 2 different methods

-          variables declared in subprograms are often dynamically allocated

-          recursion adds the possibility of multiple activations of a subprogram

-          Algol-like languages use static scoping to provide access to non-local variables