Skip to content

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)

Fill in the table below

Before After executing the instruction
PC Instruction R5R6R7R28R29R30R31
(t0)(t1)(t2)(t3)(t4)(t5)(t6)
0x000000000x000000000x000000000x000000000x000000000x000000000x00000000
0x00400000 addi t1 zero 4 0x000000000x000000040x000000000x000000000x000000000x000000000x00000000