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

Please Help!! Write a MIPS program using Mar\'s simulator Inputs: A predefined a

ID: 3690861 • Letter: P

Question

Please Help!!

Write a MIPS program using Mar's simulator

Inputs:
A predefined array. The size of the array is 100
Outputs:
1) The sum of all even digits
2) The sum of all odd digits
Requirements:
Please use “loop unrolling” & “rescheduling” to optimize your code.
Use 5-stage pipeline to explain your rescheduling strategy.
Array:
7 99 100 90 34 30 10 29 64 29 88 19 55 98 5 86 68 5 29 60 51 100 39 55
24 52 46 58 76 16 59 37 47 7 57 31 11 23 82 88 76 86 22 73 63 66 41 98
36 82 51 54 7 95 71 19 36 67 46 30 27 36 91 60 94 86 33 47 22 36 64 78
55 83 86 21 22 78 62 29 93 27 93 11 18 47 87 44 18 39 50 90 42 4 3 80
61 99 55 81

Explanation / Answer

Label   Op-Code          Dest.    S1,S2   Comments    

            .data

array:   .word   7 99 100 90 34 30 10 29 64 29 88 19 55 98 5 86 68 5 29 60 51 100 39 55 24 52 46 58 76 16 59 37 47 7 57 31 11 23 82 88 76 86 22 73 63 66 41 98 36 82 51 54 7 95 7 1 19 36 67 46 30 27 36 91 60 94 86 33 47 22 36 64 78 55 83 86 21 22 78 62 29 93 27 93 11 18 47 87 44 18 39 50 90 42 4 3 80 61 99 55 81

            .text

main:

            la         $a1,array                     # $a1 = &array

            li          $a0, 0              # $a0 = 0

loop:

            lw        $t0,0($a1)                    # $t0 = Mem($a1)

            beqz     $t0, done

            addi     $a1, $a1, 2                   # $a1 = $a1 + 2(generating even numbers in register $a1)

            andi     $t3, $t0, 1                    # $t3 = LSB of $t0

            bnez     $t3, odd                       # branch if odd

            bltz      $t0, loop

            add      $a0, $a0, $t0    # $t2 = $t2 + $t0       

            b          loop

              li      $v0, 4

           la      $t1, even

           syscall                                # print out "Even Sum = "

            li      $v0, 1

         move    $t1, $a0

           syscall                      # print out actual sum

odd:  

            bgtz      $t0, loop

           add      $a0, $a0, $t0    # $a0 = $a0 +$t0

            b          loop

               li      $v0, 4

           la      $t1, odd1

           syscall                                # print out "odd Sum = "

             li      $v0, 1

          move    $t1, $a0

            syscall                      # print out actual sum

done:

            li          $v0,     1          # Print result syscall(1)

            syscall

exit:

    li      $v0, 10              # terminate program run and

    syscall                      # Exit

                       .data

even:         .asciiz "Sum of Even = "

odd1:         .asciiz "Sum of Odd = "

output:

Sum of Even =2972

Sum of Odd =2170

##Note-----This program helps u in even positive and negative numbers