Question

Convert the for loop into MIPS instructions. Use the slt instruction to determine the branch. Be...

Convert the for loop into MIPS instructions. Use the slt instruction to determine the branch. Be sure to initialize i properly.

for (int i = 1; i < 7; i++)

value = value + i;

i: $t0, value: $s0

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MIPS instructions for above loop:

li $t0, 1 # t0 is initialized to 1

loop: # it is label for loop

add $s0, $s0, $t0 # value of t0 is added to s0 and stored back in s0

addi $t0, $t0, 1 # t0 is incremented by 1

slt $t1, $t0, 7 # If t0 < 7 then t1 = 1, otherwise 0.

bne $t1, $zero, loop #if t1 = 0 then the loop will exit, else it will continue

Add a comment
Know the answer?
Add Answer to:
Convert the for loop into MIPS instructions. Use the slt instruction to determine the branch. Be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT