1. Assume that variables i, and j are assigned to registers $s3 and $s4, respect
ID: 441141 • Letter: 1
Question
1. Assume that variables i, and j are assigned to registers $s3 and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s5 and $s6, respectively. What is the corresponding MIPS assembly code for the following C statement: A[4] = i-j; B[8] = A[5]; 2.Convert the pseudo-C code above into reasonably efficient MIPS code. Assume that variables a, b, c, and d are assigned to registers $t0, $t1, $t2, and $t3, respectively. int a,b,c,d; a=b=10; // initialize a and b to 10 for(c=0; c<4; c++) { d=a; // save a to temporary location d a+=b; // a = a + b b=d; // b = a }Explanation / Answer
The address of a[4] can be achieved by address of a + 4 Hence the answer is First calculate i-j and store in $t0 and move it to the array[4]. subl $t0,$s3,$s4 move $(s5+4),$t0 Cheers! Please rate :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.