Question

For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables i andj are assigned to

0 0
Add a comment Improve this question Transcribed image text
Answer #1
# i, j in $s0, $s1
# A, B in $s6, $s7
# B[i] = A[B[j] + 12];

sll $t0, $s1, 2     # making j indexable
add $t0, $t0, $s7   # $s0 = &B[j]
lw $t0, 0($t0)      # $t0 = B[j]
addi $t0, $t0, 12   # $t0 = B[j] + 12
sll $t0, $t0, 2     # making B[j] + 12 indexable
add $t0, $t0, $s6   # $t0 = &A[B[j] + 12]
lw $t0, 0($t0)      # $t0 = A[B[j] + 12]

sll $t1, $s0, 2     # making i indexable
add $t1, $t1, $s7   # $t1 = &B[i]
sw $t0, 0($t1)      # B[i] = A[B[j] + 12]
Add a comment
Know the answer?
Add Answer to:
For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables...
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