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

In MIPS assembly language: In this program, you should define an array of 10 ele

ID: 3925120 • Letter: I

Question

In MIPS assembly language: In this program, you should define an array of 10 elements m your data segment with these values A ={11, 12, -10, 13, 9, 12, 14, 15, -20) Write a function which finds the maximum value of this array. Write another function which calculates the summation of this array. Call these functions in your main program, and print the outputs of these functions to the user "The maximum is 15" "The summation is 56" What is the address that has been used by the simulator for this array?

Explanation / Answer

.data

txt1:   .asciiz   "Please enter apositive integer (negative integer to exit) : "

txt2:   .asciiz   " The maximum value is : "

txt3:   .asciiz   " The minimum value is : "

txt4:   .asciiz   " The average is : "

txt5:   .asciiz   " with remainder : "

.text

.globl main

main:

    addi $s0, $zero, 0

loop:

    la $a0, txt1

    li $v0, 4

    syscall

   

    li $v0, 5

    syscall

   

    bltz $v0, average

    add $s0, $v0, 0

    add $t0, $t0, 1

    add $t3, $t3, $s0

   

    beq $t0, 1, first

    blt $s0, $t1, min

    bgt $s0, $t2, max

first:

     add $t1, $s0, 0

     add $t2, $s0, 0

     j   loop

min:

    add $t1, $s0, 0

    j   loop

max:

    add $t2, $s0, 0

    j   loop   

average:

  div $t3, $t0

    mflo $t7

    mfhi $t6

   

print:

    la $a0, txt2

    li $v0, 4

    syscall

   

    add $a0, $t2, 0

    li $v0, 1

    syscall

   

    la $a0, txt3

    li $v0, 4

    syscall

   

    add $a0, $t1, 0

    li $v0, 1

    syscall

   

   la $a0, txt4

    li $v0, 4

    syscall

   

    add $a0, $t7, 0

    li $v0, 1

    syscall

            

exit:

    li $v0, 10

    syscall

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