Question

Translate the following C code to LEGv8. Assume that the variables f, g, h, i, and...

Translate the following C code to LEGv8. Assume that the variables f, g, h, i, and j are assigned to registers X0, X1, X2, X3, and X4, respectively. Assume that the base address of the arrays A and B are in registers X6 and X7, respectively. Assume that the elements of the arrays A and B are 8-byte words:

B[8] = A[i] + A[j];

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

IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE THERE TO HELP YOU

ANSWER:

CODE:

#offset value of A[i]

sll $t0, $x3, 2

#add the address of A[i]

add $t0, $t0, $x6   

#load A[i] value to t0

lw $t0, 0($t0)

#offset value of A[j]

sll $t1, $x4, 2

#add the address of A[j]

add $t1, $t1, $x6   

#load A[j] value to t1

lw $t1, 0($t1)

#add the address t1   

add $t2, $t0, $t1   

# B[8] = A[i] + A[j]

sw $t2, 32($x7)

I HOPE IT HELPS YOU RATE THUMBSUP PLEASE

Add a comment
Know the answer?
Add Answer to:
Translate the following C code to LEGv8. Assume that the variables f, g, h, i, and...
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