Question

1. Convert the following C statement to MIPS code. Assume x, y and z are assigned...

1. Convert the following C statement to MIPS code. Assume x, y and z are assigned to registers $s0, $s1 and $s2 respectively and the starting address of array A is $s6.

x = y + z + A[3] 2.

2.Convert the following C statement to MIPS code. Assume the base address of array A is $s3 and h is assigned to register $s2

. A[7] = h + A[7]

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

1) x = y + z + A[3]

lw $t0 12($s6)      #$to = A[3]
add $t0 $t0 $s2     #$to = A[3] + z
add $s0 $t0 $s1     #x = A[3] + z + y

2)

A[7] = h + A[7]

lw $t0 28($s3)      #$to = A[7]
add $t0 $t0 $s2 #$to = A[7] + h
sw $t0  28($s3)     #A[7] = A[7] + h


Thanks, let me know if there is any concern.

Add a comment
Know the answer?
Add Answer to:
1. Convert the following C statement to MIPS code. Assume x, y and z are assigned...
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