Spring 06 CS61C Homework 10

Pipelining

Due date

Corresponding Reading

Problems

All the questions for this week are from the P&H book. Complete exercise 6.3, 6.4, 6.5, 6.17, 6.18, 6.19, 6.21, 6.22, 6.31, 6.32. Question 6.5, 6.31 and 6.32 are located in the CD. They are repeated here for your convenience.

Question 6.5

How could we modify the following code to make use of a delayed branch slot?

Loop: lw $2, 100($3)
      addi $3, $3, 4
      beq $3, $4, Loop

Question 6.31

One extension of the MIPS instruction set architecture has two new instructions called movn (move if not zero) and movz (move if zero). For example, the instruction

movn $8, $11, $4

copies the contents of register 11 into register 8, provided that the value in register 4 is nonzero (otherwise it does nothing). The movz instruction is similar but copying takes place only if the register's value is zero. Show how to use the new instructions to put whichever is larger, register 8's value or register 9's value, into register 10. If the values are equal, copy either into register 10. You may use register 1 as an extra register for temporary use. Do not use any conditional branches.

Question 6.32

The solution to Exercise 6.31 should involve the execution of fewer instructions than would be required using conditional branches. Sometimes, however, rewriting code to use movn and movz rather than conditional branches doesn't reduce the number of instructions executed. Nonetheless, even if the use of movn and movz doesn't reduce the number of instructions executed, it can still make the program faster if it is being executed on a pipelined datapath. Explain why.

Submission

You should submit your homework electronically using the command:

submit hw10

For questions that require diagram drawings, you may use any graphics drawing programs of your choice, as long as it can produce one of following output format: PDF, PNG, PS, EPS, GIF, JPG.