Due Date: 9/30/05 (wed)
Textbook Problem 2.3 (1 pt)
Textbook Problem 2.6 (2 pts)
Problem A. (2 pts) Convert the following octal numbers
and hexadecimal numbers: 736, 1453 (this was changed from 8435)
Problem B. Consider the following functions that are part of
// Returns 1 if m = n, and returns 0 otherwise
int compare(int m, int n)
if (m == n) return 1;
else return 0;
if b = b and returns 0 otherwise
int compArray(int b)
(a) (1 pt) Write a MIPS assembly language
assuming the values of m and n are passed through $a0 and $a1, respectively. In
the returned value is passed through $2. You may use
$t0 for temporary storage (if you need it). Your implementation
take five instructions or less.
(b) (1pt)Write a MIPS assembly language implementation of
compArray, which calls function compare. Assuming its input
is passed through $a0. In particular, the address to b[ ] is passed through $a0 (i.e., $a0 has the address to b). In addition,
returned value is passed through $2. You may use
$t0 and $t1 for temporary storage
you need them) but no other registers. You may use the stack for
storage, and so you may change the value of $sp. (You do not need
use the frame pointer.) Note that compArray calls compare, so
implementation should be consistent with your answer in part (a).
implementation should take 14 instructions or less.
Problem C. Write the 6-bit signed-magnitude, ones
and twos complement representations of the following values.
label which representations you are using.)
(a) (1 pt) - 11
(b) (1 pt) + 17
(c) (1 pt) - 13
Problem D. Consider the following additions of 4-bit twos-complement numbers. Which of the additions result in overflow.
(a) (1 pt)
(b) (1 pt)
(c) (1 pt)