Exercise 1
Based on Patterson & Hennessy, pages 54–56. Step through the program below instruction by instruction and fill in the table, recording the PC value, the instruction being executed, and the value of the modified registers after each instruction.
Exercise
Assembly Code
# C expression: f = (g + h) - (i + j)
.text
main:
addi t1, zero, 4 # g = 4
addi t2, zero, 3 # h = 3
addi t3, zero, 2 # i = 2
addi t4, zero, 1 # j = 1
add t5, t1, t2 # t5 = g + h
add t6, t3, t4 # t6 = i + j
sub t0, t5, t6 # f = t5 - t6 (result in t0)