# MCS-284 Chapter 3 Homework

• 3.x1: All numerals in this problem are given in six bit wide two's complement signed notation, and your answers should be too. Answer each of the following arithmetic problems. For each, indicate if an overflow occured.
1. 010010 + 000011 =
2. 010111 + 110001 =
3. 011010 - 101100 =
4. 111001 - 000011 =
Lastly, check you answers by converting all numbers to base 10. When an exception occurs, how far off is the base 10 answer?

• 3.30 on page 232.

• 3.36 on page 232.

• 3.40 on page 232.

• 3.x2: (from an old exam) Multiplies can be accomplished by left shifts if the multiplier is a power of two. The goal of this problem is to compute which is better when multiplying by 25.
1. Fill in the blanks so that the MIPS code performs multiply via left shifts. Assume the multiplicand starts in register `\$a0` and the multiplier is in register `\$a1`. The least significant bits of the product will be left in `\$v0`. The most significant bits and any overflow are ignored. Note that `srl` is a shift-immediate instruction, while `shl` is not immediate.
```        li   \$t1, -1
loop: