Skip to main content
Engineering LibreTexts

6.5: Exercises

  • Page ID
    28534
    1. Why do "la label" instructions always need to be translated into 2 lines of pseudo code? What about "lw label" instructions? Explain the similarities and differences in how they are implemented in MARS.
    2. The following table has memory addresses in each row, and columns which represent each of the MIPS boundary types, byte, half word, word, and double word. Put a check mark in the column if the address for that row falls on the boundary type for the column.

      Address

      Boundary Type

      Byte

      Half

      Word

      Double

      0x10010011

      0x10010100

      0x10050108

      0x1005010c

      0x1005010d

      0x1005010e

      0x1005010f

      0x10070104

    3. The following program fails to load the value 8 into $t0. In fact it creates an exception. Why?
      .text
          lui $t0, 1001
          lw $a0, 0($t0)
          li $v0, 1
          syscall
          li $v0, 10
          syscall
      .data
          .word 8
      
    4. Translate the following pseudo code into MIPS assembly to show each of the addressing modes covered in this chapter. Note that variables x and y are static and volatile, so should be stored in data memory. When using register direct access, you do not need to store the variables in memory.
      main() {
          static volatile int miles = prompt("Enter the number of miles driven: ");
          static volatile int gallons = prompt("Enter the number of gallons used: ");
          static volatile int mpg = miles / gallons;
          output("Your mpg = " + mpg);
      }
      
    • Was this article helpful?