Created 07/07/03

# on Frame-based Linkage

This is a practice quiz. The results are not recorded anywhere and do not affect your grade. The questions on this quiz might not appear in any quiz or test that does count toward your grade.

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.

1. In a high-level language, how is a local variable implemented?

A. As a section of global memory.
B. On the run-time heap.
C. As a slot in an array.
D. As a location on a subroutine's stack-frame.

2. What registers are the caller-saved registers?

A. The "T" registers.
B. The "V" registers.
C. The "S" registers.
D. The "A" registers.

3. For us, how many bytes are in each item on the stack?

A. 1
B. 2
C. 4
D. 8

4. What is the role of `$fp` with a stack frame?

A. `$fp` is used when values are popped and pushed during arithmetic evaluation.
B. `$fp` points at the section of the stack that does not change as a subroutine executes.
C. `$fp` is used to access values that the caller saved on the stack.
D. `$fp` points at global values all subroutines may access.

5. Does the number of registers that MIPS has limit the number of variables that a subroutine may have?

A. No, because each register may be used for any number of variables.
B. No, because variables are implemented as locations on the stack.
C. Yes, there may be only 32 variables in a program, minus the number of registers used for special purposes.
D. Yes, there may be only 8 variables in a program.

6. In the programming language "C", what is the name for variables implemented as sections of the run-time stack?

A. automatic
B. dynamic
C. stack
D. heap

7. What is it called when a subroutine may call itself?

A. automatic
B. dynamic
C. static
D. recursive

8. When is space made on the stack for the local variables of a subroutine?

A. In the subroutine call of the caller.
B. In the subroutine's prolog.
C. In the subroutine's main body.
D. In the subroutine's epilog.

9. A subroutine has just one variable. How is that variable copied into $t0 in the subroutine's body?

A. `lw $t0,0($fp)`
B. `lw $t0,0($sp)`
C. `lw $t0,4($fp)`
D. `lw $t0,-4($fp)`

10. A subroutine has 3 local variables. How does it allocate space on the stack for these variables?

A. `addu $fp,$sp,12`
B. `addu $fp,$sp,3`
C. `subu $fp,$sp,12`
D. `addu $sp,$fp,12`

The number you got right: Percent Correct: Letter Grade:

If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the SHIFT KEY while clicking to clear the old answers.