Created 6/29/03

# on Loops and Branches

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. How many bytes are used for an ASCII-encoded character?

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

2. What assembler directive puts a null-terminated string in memory?

A. .ascii "Hello World"
B. .text "Hello World"
C. .word "Hello World"
D. .asciiz "Hello World"

3. How is a null-terminated string arranged in memory?

A. Characters are grouped four to a full word from right to left. Extra space at the end is filled with zeros.
B. Characters are put in sequential order with a null byte after the last character.
C. Characters are put in sequential order one per word with a word of null after the last character.
D. Characters are put in sequential order in memory. Space characters are replaced with null bytes.

4. A character has been loaded into a register by using a `lbu` instruction. What does the register look like?

A. The character is in the low-order byte. The three high-order bytes are zero.
B. The character is in the low-order byte. The three high-order bytes are whatever they were just before the instruction.
C. The character is in the high-order byte. The three low-order bytes are zero.
D. The character is in the low-order byte. The three high-order bytes contain one-bits.

5. How is a character pointer typically moved from one character to the next?

A. It is incremented by four with a `addiu` instruction.
B. It is incremented by one with a `add` instruction.
C. It is incremented by one with a `addiu` instruction.
D. It is changed with a `move` instruction.

6. How is an array of integers typically implemented?

A. The integers of the array are put in sequential words of memory. A word of zeros follows the last integer.
B. The integers of the array are put in sequential words of memory. Another word of memory contains the length of the array.
C. The integers of the array are put in sequential bytes of memory. The last byte holds the length of the array.
D. Each integer of the array is assigned to one of the general purpose registers.

7. What instruction can be used to load register $10 with the first address of the `.data` section?

A. `lui $10,0x1000`
B. `lui $10,0x10000000`
C. `ori $10,0x1000`
D. `andi $10,0x4000`

8. How much should a base register be incremented by to move from one integer to the next in an array of integers?

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

9. Say that register $8 contains an integer and that register $9 contains a sum. The integer is to be added to the sum only if it is positive. Which of the following code sequences does this?

A.
            bltz   $8,noadd
            sll    $0,$0,0
            addu   $9,$9,$8
    noadd:
B.
            bltz   $8,noadd
            addu   $9,$9,$8
    noadd:
C.
            blgez  $8,noadd
            sll    $0,$0,0
            addu   $9,$9,$8
    noadd:
D.
            slt    $5,$8,$0
            beq    $5,$0,noadd
            sll    $0,$0,0
            addu   $9,$9,$8
    noadd:

10. When the SPIM simulator is set to "bare machine" to what value should the PC be initilized?

A. 0x00000000
B. 0x10000000
C. 0x100000
D. 0x400000

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.