Created 07/03/03

# on Simple Subroutine 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. What is the major limitation in using a jump instruction to pass control to a subroutine?

A. The subroutine can not be passed any arguments.
B. The jump instruction is too slow for subroutine calls.
C. Subroutines are often distant in memory from the main routine, and the jump instruction can not reach them.
D. The jump instruction gives the subroutine no information about the return address.

2. A `main` routine passes control to a subroutine `subA`. Which of the following is usually true?

A. When `subA` is done it returns control to `main` a few statements after the call.
B. When `subA` is done it always returns control to the same place in `main`.
C. When `subA` is done it returns control to the operating system.
D. When `subA` is done the whole program is finished.

3. What is a return address?

A. ... the address in the subroutine that gets control.
B. ... the address of the instruction that calls a subroutine.
C. ... the address of the instruction in the caller to which the subroutine returns control.
D. ... the address in the subroutine of the instruction that returns control to the caller.

4. Recall how the `jal` instruction works:

    jal sub    # $ra <― PC+4  $ra <― address 8 bytes away from the jal
               # PC  <― sub   load the PC with the subroutine entry point

Say that the `jal` instruction is at address `0x400000`. The subroutine `sub` is at address `0x400300`.

What is in $ra after the `jal` instruction executes?

A. `$ra==0x400004`
B. `$ra==0x400008`
C. `$ra==0x400300`
D. `$ra==0x400308`

5. Is the `jal` instruction followed by a branch delay?

A. No.
B. Yes.

6. What does the following instruction do?

    jr  $s0

A. It immediately jumps to the address in $s0 with no branch delay.
B. It jumps to the address in $ra after a one instruction branch delay.
C. It jumps to the address in $s0 after a one instruction branch delay.
D. The instruction is illegal.

7. By software convention, which registers must a subroutine NOT change?

A. $t0 - $t9
B. $s0 - $s7
C. $a0 - $a3
D. $v0 - $v1

8. By software convention, which registers MAY a subroutine change?

A. $t0 - $t9
B. $s0 - $s7
C. $a0 - $a3
D. $v0 - $v1

9. What is the name for a symbol in a subroutine that is made visible to other routines?

A. local symbol
B. express symbol
C. global symbol
D. universal symbol

10. With the simple linkage convention, is it possible for `main` to call a subroutine which then calls another subroutine?

A. Yes. Subroutines will return to their caller in the opposite order they were called.
B. Yes. The `jal` and `jr` instructions automatically allow this.
C. No. The first subroutine can't use a `jal` instruction without destroying the return address to `main`.
D. No. This is never done in programming.

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.