COMPUTER ORGANIZATION                     September 10, 2002

WC3824-001 (CSEE) HOMEWORK #1
PROF. TONY JEBARA

 

 

DUE

THURSDAY, SEPTEMBER 19th, 2002 AT BEGINNING OF CLASS

 

 

Write all code examples in MIPS assembly without using pseudo-instructions. Only use MIPS instructions we covered in class and in Patterson/Hennessy Sec. 3.1-3.8.

 

 

1. (5 points): Patterson and Hennessy Exercise 3.1.

 

2. (10 points): Patterson and Hennessy Exercise 3.5.

 

3. (10 points): Patterson and Hennessy Exercise 3.6. You don’t really need a simulator to do this problem, do it on paper instead.

 

4. (15 points): Patterson and Hennessy Exercise 3.10.

 

5. (20 points): Patterson and Hennessy Exercise 3.11.

 

6. (10 points): Patterson and Hennessy Exercise 3.21.

 

7. (10 points): Transform the following C code into MIPS assembly code:

 

          i=1;

          res=0;

          while (i<=n)

{

                    res = res + i;

                    i = i + 1;

}

 

Assume the following registers contain the variables: i is stored in $15, res is stored in $16 and n is stored in $17. How many total instructions did the program use if n was 10?

 

8. (20 points): Transform the following C code into MIPS assembly code:

 

          for (i=0; i<=100; i=i+1)

{

                    if (a[i] < b[i]) a[i] = b[i];

                    else b[i] = a[i] + c;

}

 

Assume the following registers contain the variables: i is stored in $15, c is stored in $16, the starting address of the array a is stored in $17 and the starting address of the array b is stored in $18. How many total lw and sw instructions did your program use? How many total instructions did the program use?

 

9. (Optional, 0 points) Digital Logic: You are given the following Boolean equation: X = D + (C’ + (E*F)). Draw the corresponding gate-level circuit using AND, OR and NOT gates. Here, an apostrophe after a variable indicates that the variable is negated or inverted (thus, C’ means the same thing as drawing a vertical bar above C).

 

10. (Optional, 0 points) Binary and Hex: Given the base-10 or decimal number 218, (a) write the number in base-2 or binary equivalent and (b) convert the base-2 answer into base-16 or hexadecimal.

 

11. (Optional, 0 points) Digital Logic: Consider a circuit which takes three inputs (A,B,C) and produces one output (Z). The Z value is one if-and-only-if an even number of the inputs are one. Otherwise Z is zero.  Draw such a circuit at the gate-level circuit using AND, OR and NOT gates.