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

I need to convert this C code to MIPS, I have the program mostly done I am just

ID: 3549893 • Letter: I

Question

I need to convert this C code to MIPS, I have the program mostly done I am just stuck on the for loop part void main() { int numbers[11] = {6, 4, 2, 7, 5, 22, 7, 2, 5, 2, 7} ? int check, count? int i? printf("Enter an integer: ")? //read an integer from a user input and store it in check scanf("%d", &check)? count = 0? for (i = 0? i < 11? i++) { if (numbers[i] > check) { count = count+1? } } printf( "The count of the integers that are greater than %d is: %d ", check, count)? return? The following is a sample output (user input is 2): Enter an integer: 2 The count of the integers that are greater than 2 is: 3

Explanation / Answer

please rate - thanks

any questions ask






   .text
    .globl main

main:    la $s0,numbers    #intialize the array pointers          
         li $s1,11          #get size
         li $t2,0        # count=0
         la $a0,enter
         li $v0 4
         syscall        #ask for input
         li $v0,5
         syscall         #get number
         move $t1,$v0    #and but in t1
loop:
        lw $t0,0($s0)    #get array element
        sub $t0,$t0,$t1 #sub what looking for from number
        blez $t0,next     #if >0 it's bigger
        addi $t2,$t2,1
next:   addi $s1,$s1,-1   #count down
        blez $s1,done     #all numbers checked?
        addi $s0,4            
        j loop   

done:
         la $a0,count
         li $v0,4
         syscall
         move $a0,$t1
         li $v0,1
         syscall
         la $a0,is
         li $v0,4
         syscall
         move $a0,$t2
         li $v0,1
         syscall
         la $a0,nl
         li $v0,4
         syscall
         li $v0,10
         syscall
    .data
size:        .word   4
numbers: .word 4, 6,4,2,7,5,22,7,2,5,2,7
enter:   .asciiz "Enter an integer: "  
count:   .asciiz "The count of the integers greater than "  
is:     .asciiz " is "
nl:     .asciiz " "



Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote