Consider thefollowing C code: do j = j +1 while (A[i++] >=10|| A[i] < 0); Fill i
ID: 3609340 • Letter: C
Question
Consider thefollowing C code:
do j = j +1
while (A[i++] >=10|| A[i] < 0);
Fill in the blanksin the following translation of this C code into MIPS:
Assume$s3 = i, $s4 =j, $s5 = @A.Below is the MIPS code:
Loop: addi $s4,$s4,1 #j = j + 1?
add $t1,$s3,$s3 # $t1= 2 *i
add ___________ # $t1= 4 * i
add $t1,$t1,$s5 # $t1= @ A[i]
lw __________ # $t0 =A[i]
addi $s3,$s3,4 # i = i+ 1?
slti $t1,$t0,10 # $t1= $t0 < 10?
____ ___,$0, Loop #goto Loop if >=
slti $t1,$t0, 0 # $t1= $t0 < 0?
____ ___,$0, Loop #goto Loop if <
Explanation / Answer
onsider thefollowing C code:
do j = j +1
while (A[i++] >=10|| A[i] < 0);
Fill in the blanksin the following translation of this C code into MIPS:
Assume$s3 = i, $s4 =j, $s5 = @A.Below is the MIPS code:
Loop: addi $s4,$s4,1 #j = j + 1?
add $t1,$s3,$s3 # $t1= 2 *i
add ___$t1,$t1,$t1________ # $t1 = 4 * i
add $t1,$t1,$s5 # $t1= @ A[i]
lw ____$t0,0($t1)______ # $t0 = A[i]
addi $s3,$s3,4 # i = i+ 1?
slti $t1,$t0,10 # $t1= $t0 < 10?
__beq $t1___,$0, Loop # goto Loop if >=
slti $t1,$t0, 0 # $t1= $t0 < 0?
___bne $t1_ ___,$0, Loop # goto Loop if <