plz can we solve it with details and tell us why we do this work REFERE MAILINGS
ID: 3902668 • Letter: P
Question
plz can we solve it with details and tell us why we do this work
REFERE MAILINGS REVIEW VEw T Normal No Spac... Heading 1 Heading 2Tle Paragraph Styles 2.3 For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables f, E,H i, and j are assigned to registers A and B are in registers $s6 and $s7, respectively. Ss0, Ss1, Ss2, Ss3, and Sa4, respectively. Assume that the base address of the arrays 2.4 For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables £ g, h, i, and j are assigned to registers Ss0, Ss1, Ss2, Ss3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and Ss7, respectively s11 St1S21, 2 # St1 g*4 &B;[3] add Sti, Ss7, Sti # Sti addi $t2, St0, 4 add Sto, $t0, Ss0Explanation / Answer
1. SUB $t0, $s3, $s4 # t0 = i - j, i is stored in register $s3 and j is stored in register $s4
lw $t1, t0($s6) # In t1 register I am loading the value present in A[t0] and base address of A is stored in s6 reg
sw $t1, 8($s7) # Finally I am storing the value obtained in t1 register to the 8th index of B whose base address is stored in s7 register.
2. sll $t0, $s0, 2 # C code:- t0 = f << 2;
add $t0, $s6, $t0 # C code:- t0 = A[0] + t0; as $s6 will store the base address of A and it points to A[0] element
sll $t1, $s1, 2 # C Code:- t1 = g << 2;
add $t1, $s7, $t1 # C Code:- t1 = B[0] + t1 as $s7 will store the base address of B and it points to B[0] element
lw $s0, 0($t0) # C Code:- f = t0[0] load in ref f the value at index 0 present in t0 array
addi $t2, $t0, 4 # C Code:- t2 = t0 + 4, here we are adding the value stored in reg t0 with 4
Please let me know in case of any clarifications required. Thanks!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.