Computer Science and Engineering 477



14:332:331

Midterm Examination #2

Fall 2002

Name: __________________________________________

S.S.#: _______________________________

|1 |40 | |

|2 |30 | |

|3 |30 | |

|Total |100 | |

Instructions:

This exam contains 3 questions. It is closed book and notes. Calculators are allowed. Do all of your work on the attached sheets.

Please make sure that you finish all the questions.

(31 pts) 1. Short Answer

A. (5 pt) Describe the condition for an overflow to occur when executing MIPS instruction add $s0, $s1, $s2 .

CarryIn MSB is not equal to CarryOut MSB

B. (10 pt) Instead of using a special hardware multiplier, it is possible to multiply using shift instructions and add instructions. This is particularly attractive when multiplying by small constants. Suppose we want to put 9 times the value of $s2 into $s3 ignoring any overflow that may occur. Give the minimal sequence of MIPS instructions to perform $s3 ( $s2 * 9 using only add instructions and shift instructions. As a reminder the syntax for the MIPS shift left logical (sll) instruction is

sll $t2, $s0, 8 #$t2 = $s0 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download