Question

Compile the following C for-loop into MIPS assembly code assuming the variable mapping shown below. Also assume the amay A holds integers. for (i 0; i<100 i++) x-0 for (j i+1; 100; j++) Alij

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

main:
  
   li   $s1, i           # i
   li   $s2, j           # j
   li    $s3, x
   li    $s0, A
$L8:
   addiu   $s2,$s2,1       #x+A[j];
$L11:
   movz   $s3,$s3,$0       #x=0
   slt       $s0,$s2,100    #j<100
   bne       $s0,$0,$L11       # branch to L11 if $j=0
   addiu   $s2,$s2,1       #j = j+1

   addiu   $s1,$s1,1       #i++
   slt       $s2,$s1,100       # i<100
   beq       $s2,$0,$L3       # branch to L3 if $j=0
   nop

   b       $L8
   move   $s2,$s1

$L3:
   j       $s3
   move   $s2,$0

Add a comment
Know the answer?
Add Answer to:
Compile the following C while loop into MIPS assembly code assuming the following register-variable mapping shown...
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