Write the corresponding MIPS I instruction to the C++ code segment below.
for (; i < 100; i ++) s = s + (2*i + 1);
Variable | i | s |
Register | $t0 | $t1 |
1 # Use $t2 as the destination reg.
2
3 # Use $t3 as the destination reg.
4 # Use $t4 as the destination reg.
5
6
7
8
... DONE:
Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate
the question. Thank You So Much.
screen shot of code
code.asm
#i is in $t0
#s is in $t1
#initialize s to 0
li $t1,0
LOOP:
#check if i==100 jump to done
beq $t0,100,DONE
#get 2*i
mul $t2,$t0,2
#get 2*i+1
add $t2,$t2,1
#s = s +2*i+1
add $t1,$t1,$t2
#i++
add $t0,$t0,1
j LOOP
DONE:
Get Answers For Free
Most questions answered within 1 hours.