Created 6/26/03; replaced question 7 (thanks to Z. Li) 05/22/11; 07/07/15


Quiz on Set Instructions

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

        ori      $3,$0,25
        slti     $5,$3,53

What value is in $5 after both instructions exectute?

A.    0
B.    1
C.    25
D.    53

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, look at the description of each instruction and notice what the "u" means for each.)

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:   


Click here

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.