Problem Set 4, Thinking about MIPS Assembly

Due Tuesday, February 1 @ 11:59PM

Submit your answers to blackboard. Be sure to show your work (if necessary).

  1. Given the following C statement:
    a += 2;
    What is the corresponding MIPS assembly?
  2. Given the following C statement:
    a = 3;
    a = a + someArray[3];
    What is the corresponding MIPS assembly? (Assume the base address of someArray is stored in $s3.)
  3. Given the following assembly instructions:
    addi $s6, $s6, -20
    add $s6, $s6, $s1
    lw $s0, 8($s6)
    What is the corresponding C statement(s)?
  4. Given the following 32-bit number, 1001-1110-0000-1010-0001-1100-0101-0010, how would this be stored in MIPS memory? Be sure to annotate the relative byte addresses (you may start at 0).

  5. Rubric (40 points)

    You should have read about addi, constants, and register $zero.

    1. addi $s0, $s0, 2
    2. addi $s0, $zero, 3
      lw $t0, 12($s3)
      add $s0, $s0, $t0
    3. Note that the variable names are arbitrary for this exercise.
      x = x - 20;
      x = x + y;
      z = someArrayOfCandy[2];
    4. MIPS is 32-bit, byte-addressed big-endian. Therefore:
      Address 0 1 2 3
      Value 1001-1110 0000-1010 0001-1100 0101-0010