Homework 3
CS 345
Computer Organization
10 Points
Due Monday, Feb. 9, 2015 at the beginning of class
You must submit a soft or hard copy of this assignment and show all work!

1. Convert the following Java/C mathematical statements to MIPS assembly language.
    a) a = b + c * d - e
    b) a = a - 3
    c) x = (y + z) * (z - y)
    d) f = (1 - x) * (1 + x) + 100*(y + x*x)*(y - x*x)

2. Showing all work, convert the following numbers:
    a) 1101001 from binary to decimal (hint: use powers of two)
    b) 0111 1100 0100 1001 0110 1010 1011 1101 from binary to hexadecimal
    c) 18324 from decimal to binary (hint: use division by two)
    d) Convert the result from c) to hexadecimal

3. Write an assembly program that will print on separate lines your name, the course name,  the course number as an integer, and your career goals.  Include a copy of your commented assembly program.

4. Modify the example programs from the course website to read in two integer values and print the sum, product, and modulo (division remainder) of the result.  Include a hard copy of your commented assembly program.

5.  Assume you have an array of 10 integers declared and initialized using the following C statement:

int arr[10] = { 20, 18, 16, 14, 12, 10, 8, 6, 4, 2 };

Write corresponding assembly statements for the following C statements assuming the starting address of arr is stored in $s1:

a) printf("%d", arr[2]);
b) int x = arr[2] + arr[6];  //assume x is a register
c) arr[7] = arr[4];
d) arr[0] = arr[3] + arr[6] * 3;