Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Convert the following C program to MIPS assembly code a=0.0; for (i=1; i<10; i=i

ID: 3531796 • Letter: C

Question

Convert the following C program to MIPS assembly code a=0.0; for (i=1; i<10; i=i+1) if (a > b[i]) a=a-b[i]; where a is a single-precision floating-point number stored in register $f0. i is an integer stored in register $s0. b is a single-precision floating-point array with starting address stored in register $s1 Convert the following C program to MIPS assembly code a=0.0; for (i=1; i<10; i=i+1) if (a > b[i]) a=a-b[i]; where a is a single-precision floating-point number stored in register $f0. i is an integer stored in register $s0. b is a single-precision floating-point array with starting address stored in register $s1

Explanation / Answer

li.s $f0,0.0

li $t0,10 # load constant 10

li $s0,1

loop:

beq $s0,$t0,end

c.le.s $s0,0($f1)

bclt endif

sub.s $f0,$f0,0($f1)

endif:

addi $s0,$s0,1

addi $s1.$s1,4

j loop

end: