Given the following high level Instructions convert Into MIP
Given the following high level Instructions, convert Into MIPS Instructions Convert the for loop into MIPS Instructions. Use the sit Instruction to determine the branch. Be sure to initialize I properly. for (int i = 1; i min && i
Solution
Answer
a.
lui $t0, 1
lui $t1, 7
lui $s0, 0
L1: slt $d, $t0, $t1
add $s0, $s0, $d
addi $t0, $t0, 1
bgt $t0, $t1, END
j L1
END:
b.
lui $t0, i
lui $t1, min
lui $t2, max
lui $s0, base_address
lw $s1, 0($s0)
L1: slt $d, $t0, $t1 #if i < min
beq $d, 1, SET0 #sets 0
slt $d, $t0, $t2 #if i < max
beq $d, 1, SET1 # at this point i>min and i < max
SET0: lui $s1, 0
SET1: lui $s1, 1
END
