**Due Date:** 9/30/05 (wed)

**Assignment:**

**Textbook Problem 2.3** (1 pt)

**Textbook Problem 2.6** (2 pts)

**Problem A. **(2 pts) Convert the following octal numbers
into binary

and hexadecimal numbers: 736, 1453 (this was changed
from 8435)

**Problem B**. Consider the following functions that are part of
a
C program:

// Returns 1 if m = n, and returns 0 otherwise

int compare(int m, int n)

{

if (m == n) return 1;

else return 0;

}

// Returns
1
if b[0] = b[10] and returns 0 otherwise

int compArray(int b[])

{

return compare(b[0],b[10]);

}

**(a)** (1 pt) Write a MIPS assembly language
implementation
of compare
assuming the values of m and n are passed through $a0 and $a1, respectively. In
addition,
the returned value is passed through $2. You may use
register
$t0 for temporary storage (if you need it). Your implementation
should
take five instructions or less.

**(b)** (1pt)Write a MIPS assembly language implementation of
function
compArray, which calls function compare. Assuming its input
parameter
is passed through $a0. In particular, the address to b[ ] is passed through $a0 (i.e., $a0 has the address to b[0]). In addition,
the
returned value is passed through $2. You may use
registers
$t0 and $t1 for temporary storage
(if
you need them) but no other registers. You may use the stack for
temporary
storage, and so you may change the value of $sp. (You do not need
to
use the frame pointer.) Note that compArray calls compare, so
your
implementation should be consistent with your answer in part (a).
Your
implementation should take 14 instructions or less.

**Problem C.** Write the 6-bit signed-magnitude, ones
complement,
and twos complement representations of the following values.
(Clearly
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)

1110

__+0100__

**(b)** (1 pt)

0110

__+0010__

**(c)** (1 pt)

1100

__+1000__