Question

Write the MIPS assembly instructions corresponding to the following high level instruction. The used base register is $s2 for Al] and $s1 for F[]. and s 1 for F[6]A[4] +5
0 0
Add a comment Improve this question Transcribed image text
Answer #1

li $t2, 4 # put the index into $t2

add $t2, $t2, $t2 # double the index

add $t2, $t2, $t2 # double the index again (now 4x)

add $t1, $t2, $s2 # combine the two components of the address

lw $t3, 0($t1) # get the value from the array cell

add $t4, t4, 5 # add 5 to the value of the array cell

li $x2, 4 # put the index into $x2

add $x2, $x2, $x2 # double the index

add $x2, $x2, $x2 # double the index again (now 4x)

add $x1, $x2, $s1 # combine the two components of the address

sw $t4, 0($x1) # store the value into the array cell F[4]

NOTE: To access the data in the array requires that we know the address of the data and then use the load word (lw) or store word (sw) instructions. Words (which is how integers are stored) in MIPS take up 32 bits or 4 bytes. This is the reason I am doing 4x.

Add a comment
Know the answer?
Add Answer to:
Write the MIPS assembly instructions corresponding to the following high level instruction. The used base register...
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