Skip to main content
Engineering LibreTexts

6.5: Exercises

  • Page ID
    28534
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    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);
      }
      

    This page titled 6.5: Exercises is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Charles W. Kann III.

    • Was this article helpful?