=========================preview======================
(COMP180)quiz01S_sol2.pdf
Back to COMP180 Login to download
======================================================
Solution for Quiz #2 (prepared by D.Y. Yeung)
1.
(a) false (b) true (c) false
(d) false (e) true (f) false
(g) true (h) false (i) true

(j) Overflow may occur but it is not detected by hardware as an exception. (This question is not counted since there is ambiguity.)
2. This is one possible answer:
slt $t2, $t0, $zero
bne $t2, $zero, neg
add $t1, $t0, $zero
j exit

neg: sub $t1, $zero, $t0
exit:

Note that you should only use real instructions but not pseudoinstructions.
3. Addition can be performed directly in hexadecimal representation as follows:
159e 5091

+ ec25 7a15
01c3 caa6

The value of $t1 is 01c3caa6.
No overflow can occur since the sign bits of the 2 operands are different.