Question: Computer Architecture Problem Use the MARS MIPS Simulator write a MIPS assembly language program that takes an array of integers and finds the maximum value

Computer Architecture Problem

Use the MARS MIPS Simulator write a MIPS assembly language program that takes an array of integers and finds the maximum value of all the integers in the array.

In this lab, use the .data section to make an array named A, and A's elements be the following values:

5,16,46,-324,65,78,24,89,21,0

Also use the .data section to have a tag named max.

max should have the maximum value of the elements of A when the program is finished.

To find the maximum element in an array of length N, use this algorithm: # initialize max to the SMALLEST value it can have

# for each of the elements in the array A, as the elements of A are accessed in a loop, # check if max is larger than the current element of A being accessed in the loop # if max is SMALLER than the current element of A being accessed in the loop, assign max to be equal to the current element

# if max is LARGER than the current element of A being accessed in the loop, do not change the value of max

# by the end of the loop the value inside max should be the largest value of the array.

A high level language pseudo-code version of this algorithm looks like this:

# max = some very small number; # for (i=1;i max) { # max = array[i] # } # }

Note that for an array of integers, each integer will be stored in a memory address that is 4 bytes away from an element that comes before it. For example, if A happened to have its first value stored in memory location 0x10010004, its second value is stored in memory location 0x10010008, its third value is stored in memory location 0x1001000c, its forth value is stored in memory location 0x10010010, its fifth value is stored in memory location 0x10010014, its sixth value is stored in memory location 0x10010018, its seventh value is stored in memory location 0x1001001c, its eight value is stored in memory location 0x10010020, and so on. Keep this in mind as you are using MARS to track the values of the array elements.

Additionally, each line of the program should have a comment explaining what the instruction on that line is doing.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!