Question

Question 7 Convert C code into MIPS code: A[11] = A[10] +Y Assume Y in $sl and base address of A in $s3 T T T Arial 3 (12pt)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

We are to Write Code Corresonding to A[11] = A[10] + Y in MIPS

IT is given that Y is stored in $s1 and base address of array A is $s3

We will follow following steps to write full code

1). We will store address of A[10] and A[11] in registers $t0 and $t1

(i) we will store 10 and 11 in register $t0 and $t1 respectively using addi

(ii) multiply the content of $t0 and $t0 by 4 using shift left operation

(iii) will add value of base address of array to $t0 and $t1 and store result in $t0 and $t1 respectively.

$t0 and $t1 now contains address of A[10] and A[11] respectively.

2).

(i)fetching A[10] in register $t2

(ii)then adding A[10] with value of Y which is stored in $s1.

3).

FINALLY we stored A[10]+Y in memory location A[11] using $t1

Following Image contains full code along with explananation of each line of code

។ who register add immediate addi addi SHI 2 ΟΥ shift lgt multiply content of $to legical SI $to, $2000, lo # $to=o+10=10 $ti

addi $t0,$zero,10 # $t0 = 10

addi $t1,$zero,11 # $t1 =11

sll $t0,$t0,2 #left shift by 2 or multiply by 4   $t0 = $t0*4

sll $t1,$t1,2 # $t1=$t*4

add $t0,$t0,$s3 # $t0 = & A[11]

add $t1,$t1,$s3 # $t1 = &A[11]

lw $t2,0($t0) #fetching A[10] in register

add $t2,$t2,$s1 # $t2 = Y+A[10]

sw $t2,0($t1) # A[11] = A[10]+Y

Add a comment
Know the answer?
Add Answer to:
Question 7 Convert C code into MIPS code: A[11] = A[10] +Y Assume Y in $sl...
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