Question: Write a MIPS program that calls procedures to compute the minimum, maximum, sum and average of the contents of an array A. Call each procedure

Write a MIPS program that calls procedures to compute the minimum, maximum, sum and average of the contents of an array A. Call each procedure using the proper techniques for argument passing. ($a0-$a3) and return value ($v0,$v1). Make sure you call each procedure separately and DO NOT combine the logic into one procedure or the mainline code. 

For all procedures, pass the memory location of A and the size of A as arguments. Use the values passed and do not depend on any other values from the calling program. Return the calculated value in $v0. 

After each procedure call, save the value returned from each procedure to the appropriate memory location and print the results to the terminal.

Rubric: Each procedure is worth 10 points. Printing and saving the results of each procedure is worth 5 points each. Implementation is worth 60 points. The remaning points are based on coding rubric.

Use the following as the start of your data segment.

.data A: .word 110,160,20,70,60,140,150, 80, 90,100, 10, 30, 40,120,130,50

size: .word 16 # length of array A

min: .word 0

max: .word 0

sum: .word 0

average: .word 0

largestInt: .word 2147483647 # You may want to use this for min procedure

Example output:

The minimum is 10

The maximum is 160

The sum is 1360

The average is 85

Challenge/Bonus question (Worth 10 extra points):

 Create another array called B in the data section using the .space directive. Make the array the same length as A.

 Write a procedure called reverseArray, which accepts the memory location of array 1 (A), the memory location of array 2(B), and the length of the arrays. This procedure will fill array 2 in reverse order of array 1. If you call reverseArray with A as array 1 and B as array 2, then 50 should be the first element in B and 110 should be the last. This procedure does not have any return values.

From the mainline, call reverseArray and AFTER calling the procedure, print array B. (You may use a procedure or print it from the mainline code.

Step by Step Solution

3.45 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Please find the code below data A word 110160207060140150 80 90100 10 30 4012013050 size word 16 len... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Organizational Behavior Questions!