Question: Q4: Compile the C-Language statement A[100] = A[0] * 2; into MIPS assembly code using the minimum number of instructions. Assume that register $s2 holds
Q4: Compile the C-Language statement A[100] = A[0] * 2; into MIPS assembly code using the minimum number of instructions. Assume that register $s2 holds the base of A (an array of integers).
Place your answer here
Q5: Assuming A is an integer array with base in $s4 and that the compiler associates the integer variables g, i, and n with the registers $s1, $s2, and $s3, respectively. What is the compiled MIPS assembly code for the following C code segment?
for (i = 0; i < n; i++)
g = g + A[i];
Place your answer here
Q6: Assume that argument registers $a0 and $a1 initially contain positive integers a and b, respectively. Assume that $v0 is used for the result.
add $t0, $0, $0
loop beq $a1, $0, exit
add $t0, $t0, $a0
addi $a1, $a1, 1
j loop
exit add $v0, $t0, $0
jr $ra
a) Add comments to the above MIPS subroutine code?
b) What does this code compute?
Place your answer here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
