Consider the following program segment (which consists of all instructions shown
ID: 3826184 • Letter: C
Question
Consider the following program segment (which consists of all instructions shown) for the MIPS architecture discussed in class. Initial values in registers pertinent to this problem are: $a0 = 4 and $t0 = 4032; the values in memory location 1232 is 4000; values are in decimal.
Beg:
lw
$t6, 1232($zero)
Top:
beq
$zero, $zero, Nex
Sec:
sw
$s7, 0($t6)
beq
$zero, $zero, End
Nex:
lw
$s7, 0($t6)
add
$t6, $t6, $a0
Key:
beq
$t6, $t0, Sec
beq
$zero, $zero, Top
End:
...
Modify the program above, incorporating the code below so that the initial values are set in registers and memory location before the instruction labelled “Beg” is executed.
addi $a0, $zero, 4
addi $t0, $zero, 4032
addi $s0, $zero, 4000
sw $s0, 1232($zero)
Beg:
lw
$t6, 1232($zero)
Top:
beq
$zero, $zero, Nex
Sec:
sw
$s7, 0($t6)
beq
$zero, $zero, End
Nex:
lw
$s7, 0($t6)
add
$t6, $t6, $a0
Key:
beq
$t6, $t0, Sec
beq
$zero, $zero, Top
End:
...
Explanation / Answer
addi $a0, $zero, 4
addi $t0, $zero, 4032
addi $s0, $zero, 4000
sw $s0, 1232($zero)
SOLUTION:
li $a0, 4
li $t0, 4032
li $t1, 4000
sw $t1, 1232($zero)