I need help with this code please its supposed to take 'n' numbers and take the average of all of the numbers in MIps assembly code   the problem is that it is not working here is the code:   .dataprompt: .asciiz "Enter the number of real numbers: ".text.globl mainmain:li $v0, 4la $a0, promptsyscallli $v0, 5syscallmove $t0, $v0li $t1, 0loop:beq $t0, $t1, endli $v0, 6syscalladdi $t1, $t1, 1j loopend:li $v0, 10syscall # Initialize $t0 to hold the sumadd $t0, $zero, $zero # Initialize $t1 to hold the countadd $t1, $zero, $zero # Start the looploop2:    # Load the current number    lw $t2, 0($a0)     # Add the current number to the sum    add $t0, $t0, $t2     # Increment the counter    addi $t1, $t1, 1     # Move to the next number   addi $a0, $a0, 4    # Continue the loop if there are more numbers   bne $t1, $a1, loop2    # Calculate the average   div $t0, $t1    # Move the result to $v0,  mflo $v0

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

I need help with this code please its supposed to take 'n' numbers and take the average of all of the numbers in MIps assembly code

 

the problem is that it is not working

here is the code:

 

.data
prompt: .asciiz "Enter the number of real numbers: "
.text
.globl main
main:
li $v0, 4
la $a0, prompt
syscall
li $v0, 5
syscall
move $t0, $v0
li $t1, 0
loop:
beq $t0, $t1, end
li $v0, 6
syscall
addi $t1, $t1, 1
j loop
end:
li $v0, 10
syscall


# Initialize $t0 to hold the sum
add $t0, $zero, $zero

# Initialize $t1 to hold the count
add $t1, $zero, $zero

# Start the loop
loop2:
    # Load the current number
    lw $t2, 0($a0)

    # Add the current number to the sum
    add $t0, $t0, $t2

    # Increment the counter
    addi $t1, $t1, 1

    # Move to the next number
   addi $a0, $a0, 4

   # Continue the loop if there are more numbers
   bne $t1, $a1, loop2

   # Calculate the average
   div $t0, $t1

   # Move the result to $v0
,  mflo $v0

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Returning value from Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education