Question: Problem 1 : Sum and Average of an Array Write a MIPS assembly program that calculates and prints the sum and the average of an
Problem : Sum and Average of an Array
Write a MIPS assembly program that calculates and prints the sum and the average of an array stored in the data section. Use integer arithmetic for simplicity. The array is defined as:
data
myArray: word
length: word # Number of elements
Requirements:
Calculate the sum of the elements in myArray.
Calculate the average as an integer by dividing the sum by the length.
Print both the sum and the average to the console.
Hints:
Use a loop to iterate through the array.
The base address of the array can be accessed using a
Use the length of the array to control the loop.
Print values using the MIPS syscall for printing integers.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
