Translate C Assembly Mips S0 S1 J A0 N Q37283657

translate c to assembly (mips) s0 =i s1=j a0=N
discount A[j+1 += N]; +discount A[j+1 += N]; + Show transcribed image text discount A[j+1 += N]; +


Answer


Answer:

Given C code:

discount += A[j*i + N];

MIPS code:

I am assuming discount is stored in $d, A is stored in $t1, and$t0 is intermediate register.

mul $t0, $s0, $s1 #$t0 = i * j

add $t0, $t0, $a0 #$t0 = i * j + N

lw $t1, 0($t0) #$t1 = A[i * j + N]

add $d, $d, $t1   #$d = $d + $t1

Please give thumbsup,if you like it. Thanks.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.