# CS 61C, Spring 2012 HW 3

## TA: Alan Christopher

Due Sunday, February 12, 2011 @ 11:59pm

Submit your solution by creating a directory named "hw3". In this directory, create a file named "hw3.txt" and put your answers inside. Then run `submit hw3`.

1. Convert the following hex numbers into decimal.
1. 0x12345678
2. Convert the binary fraction .1101 to a decimal fraction. What is ⅔ as a binary fraction?
3. Show how the data in 0x12345678 would be arranged in memory of a little endian machine and a big endian machine. Assume that the data is stored starting at address 0x0.
1. little endian
2. big endian
4. What MIPS assembly code corresponds to the C code

`f = -g + h + B[1];`

Assume f,g,h are assigned to \$s0,\$s1,\$s2 and that the base address of B is in \$s7.
5. What C code corresponds to the MIPS assembly code

```add \$s0, \$s0, \$s1 add \$s0, \$s3, \$s2 add \$s0, \$s0, \$s3```

Assume f,g,h,i are assigned to \$s0,\$s1,\$s2,\$s3.
6. Write a minimal sequence of MIPS assembly instructions that does the operation identical to

`A = B & C[0]`

7. Suppose you are given the recurrence

where T0 = 1, T1 = 1, T2 = 3. Implement a recursive function in C and MIPS that correctly computes the value of T for a given input n. Remember to follow register conventions in your MIPS code.
8. Convert the following MIPS pseudo instructions into an equivalent,minimal sequence of MIPS instructions (it's acceptable for your MIPS instructions to reference LOOP instead of a numerical offset).
1. `move \$t1, \$t2`
2. `beq \$t1, 0x17, LOOP`