NOTE: Refer to the MIPS Reference Data Card. Consider the following MIPS code: L
ID: 670394 • Letter: N
Question
NOTE: Refer to the MIPS Reference Data Card.
Consider the following MIPS code:
LOOP:
slt $t2, $zero, $t1
beq $t2, $zero, DONE
subi $t1, $t1, 1
addi $s2, $s2, 2
j LOOP
DONE:
a) Assume that register $t1 is initialized to the value 10 (in base 10), and $s2 is initialized to zero. What is the value of $s2 after executing the code segment above?
b) Convert the MIPS instructions above to C code. Assume that registers $s2 and $t1 contain the variables B and i, respectively. c) How many MIPS instructions would be executed if the register $t1 was initialized to the value N?
Explanation / Answer
Loops executes 10 times
and s2 value get decremented 10 times by 2, so value will be -20
int i;
for(i = 0 ; i < t1 ; i++)
s2 = s2 - 2;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.