Here is the answer of the tricker program.
$2 = 4 16 | 24 | $4 = 20 20 | 20 | $5 = 20 24 | 16 |
The detailed steps are described below. First the program and intial states:
addi $2, $0, 4 # (1) Memory
There: sub $4, $5, $2 # (2) address contents
lw $5, 0($4) # (3) 12 | ... |
sw $4, 0($5) # (4) 16 | 24 |
bne $4, $5, There # (5) 20 | 20 |
24 | |
$2 = ..., $4 = ..., $5 = 20 28 | ... |