Subroutine Activation Record Worksheet

Subroutine: _____________________________

Item
Size
Offset
Return value
1
0
Return address (R7)
1
1
Dynamic link (R6)
1
2
     
     
     
     
     
     
     
     
     
     
     
     
Total size of AR  
 
Subroutine calls may involve the following steps (in this order): 

 1. Pass data (parameters) to the subroutine, store the stack pointer (R6) as the dynamic link, and compute a new stack pointer for the subroutine's activation record. 
 2. Pass control to the subroutine (with JSR or JSRR instruction), store the previous program counter (R7) as the return address, and save values of other registers used in the subroutine. 
 3. Execute the subroutine, referencing parameters and variables as offsets from the current stack pointer (R6). 
 4. Return data as the return value, restore previous values of registers (other than R6 and R7), and load return address in R7. 
 5. Return control (with RET), and restore stack pointer by loading subroutine's dynamic link into R6. 
 6. Use or store return value. 

Filling in the table at left will help complete these steps. 

 

 
Fill-in the table in this order: 

1. Below the entry for dynamic link, list (in order of declaration) each parameter of the subroutine and its size (in words of memory).  
2. Below the parameters (if any) list (in order of declaration), each local variable of the subroutine and its size. 

3. Below the local variables (if any), list the registers (besides R6 and R7) whose values may be changed by the subroutine or by a subroutine called by it.  The size of each register should be shown as 1. 
4. Calculate an offset for each entry in the table.  The offset of an item is the sum of the offset and size of the item immediately before the current item in the table. 
5. Add all the sizes to get the total size of the subroutine's activation record.