Question

C code to MIPS Translate the following C command into MIPS assembly. Assume that the base address of arrays A is stored in re

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

Answer

Assume that the base address of array A is stored in the register $s1.

Th given C command is

{\color{Red} A[1] = A[2] + 7;}

The above instruction can be converted to MIPS assembly by using below three lines of code.

lw $t0, 8($s1)        #load the content of A[2] to $t0
add $t1, $t0, 7       #set $t1 to $t0 + 7
sw $t1, 4($s1)       #store content of $t1 to A[1]

Demo program with output

Edit Execute array.asm* 1 .data 2 A: .word 4, 5, 33, 72, 24 #data section #variable to store array of numbers 4text #code sec

Add a comment
Know the answer?
Add Answer to:
C code to MIPS Translate the following C command into MIPS assembly. Assume that the base...
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