Reading
H+P Chapter 1, sections 1, 2, and 3. Skim the rest of chapter 1.
H+P Chapter 3, sections 1, 2, 3, and 5.
To do on your own:
H+P Exercises 1.1-1.26. Don't worry much about definitions from section 4 onward.
To turn in:
1. H+P Exercises 1.27-1.44, 1.54.
2. H+P Exercises 3.1 and 3.2. You may find the hint in the exercise below useful. In general, if you see an instruction you don't understand, Appendix A may be helpful.
3. Here is a snippet of MIPS assembly:
start: beq $s1, $s2, exit add $t0, $s2, $s2 add $t0, $t0, $t0 lw $t1, $t0($s0) addi $t1, $t1, 1 sw $t1, $t0($s0) addi $s2, $s2, 1 j start exit:
Address | Contents |
---|---|
200 | 17 |
204 | 4 |
208 | 396 |
212 | 8 |
216 | 99 |
Register | Contents |
---|---|
$s0 | 200 |
$s1 | 5 |
$s2 | 0 |
Extra credit: Write two C snippets that would compile down to this assembly. For the first one, translate line-by-line. For the second, write more natural C, which achieves the same effect as this code while observing standard C idioms. Which do you think is more likely to come out of an automatic translation program? Which is more useful to a human?