Created 6/26/03

# on Set Instructions

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. Examine the following program fragment:

            ori   $8,$0,13
            ori   $9,$0,1
            bltz  $8,target
            sll   $0,$0,0
            ori   $9,$0,0

    target: sll   $0,$0,0       # arbitrary instruction

What value is found in $9 when control reaches target?

A. 0
B. 1
C. 4
D. 13

2. Trick Question: Examine the following program fragment:

            ori   $8,$0,-57
            ori   $9,$0,1
            bltz  $8,target
            ori   $9,$0,0       # think about the delay
                                # slot
    target: sll   $0,$0,0       # arbitrary instruction

What value is found in $9 when control reaches target?

A. 0
B. 1
C. 3
D. 4

3. Examine the following program fragment:

            ori   $8,$0,13
            ori   $9,$0,1
            bgez  $8,target
            sll   $0,$0,0
            ori   $9,$0,0

    target: sll   $0,$0,0       # arbitrary instruction

What value is found in $9 when control reaches target?

A. 0
B. 1
C. 4
D. 13

4. Examine the following program fragment (slightly different from the previous):

            ori   $8,$0,13
            bgez  $8,target
            ori   $9,$0,1
            ori   $9,$0,0

    target: sll   $0,$0,0       # arbitrary instruction

What value is found in $9 when control reaches target?

A. 0
B. 1
C. 4
D. 13

5. Examine the following program fragment:

            addiu    $3,$0,-13
            addiu    $7,$0,23
            ?????

Pick the instruction to replace `?????` that will set register $10 to one.

A. `sltu $3,$7,$10`
B. `slt $10,$7,$3`
C. `slt $10,$3,$7`
D. `sltu $10,$3,$7`

6. Examine the following program fragment:

            addiu    $3,$0,-13
            slti     $5,$3,-8

What value is in $5 after both instructions exectute?

A. 0
B. 1
C. -8
D. -13

7. Here is an instruction:

            sltiu    $5,$3,17

At execution time, all operands (even those that start as immediate operands) are 32 bits long. How does the "17" become 32 bits long?

A. By sign extention.
B. By zero extention.
C. The 32 bits in register $17 are used.
D. The 17 is added to register $3.

8. (Very Tricky:) Examine the following program fragment:

            addiu    $3,$0,-1
            sltiu    $5,$3,17

What value is in $5 after both instructions exectute? (If your answer is incorrect, run the program with SPIM and examine the registers.)

A. 0
B. 1
C. -8
D. -13

9. Which style of implementing a counting loop is usually easiest to understand?

A. data driven loop
B. bottom driven loop
C. conditional driven
D. top driven loop

10. Examine the following program fragment:

           ori    $5,$0,5       # initialize count
           ori    $8,$0,0       # initialize accumulator

    test:  bltz   $5,done
           sll    $0,$0,0
           addu   $8,$8,$5      # add count to accumulator
           addiu  $5,$5,-1
           j      test
           sll    $0,$0,0

    done:  sll    $0,$0,0

How many times is the `addu` instruction executed?

A. 0
B. 5
C. 6
D. 7

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.