Homework #2 -- due Wed Feb 1

Do the following exercises. Remember to show your work.

  1. The MIPS translation of the C segment:
           while (save[i] == k) 
              i = i + 1;
    
    on page 74 uses both a conditional branch and an unconditional jump each time through the loop. Only poor compilers would produce code with this loop overhead. Rewrite the assembly code so that it uses at most one branch or jump each time through the loop. How many instructions are executed before and after the optimization if the number of iterations of the loop is 10 (i.e. save[i], save[i+1], ..., save[i+9} equal k, but save[i+10} does not equal k)?
  2. 2.29. Here is the raw code for you to comment.
  3. 2.30. You can use the same sheet given in 2.29 above.
  4. 2.37. A few hints:

General homework requirements

Valid XHTML 1.1!