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

To be done in MARS Down below is the code where you have to add the code and und

ID: 2268730 • Letter: T

Question

To be done in MARS
Down below is the code where you have to add the code and understand it. Please also show me complete working code. Screenshot your screen and show me the result
Lab 2: Find the Maximum Objectives The goal of this lab is to implement a function with MIPS instructions to find the maximum value in an array. You will learn/practice with the following skills: Access arrays. Write simple functions. Use system calls. Steps 1. Read the sample code and understand the functions provided. The code initializes an array of words with pseudo-random numbers and print out the words in three formats: hex, signed, unsigned. You can comment out the line that calls print array when you work on your code. You can also change the number of words (stored in Ss0) to test your code. 2. Implement the find max function, which finds the index of the maximum value in a word array. The C implementation of the function is listed on the next page. Note that this function assumes signed words. Please pay attention to the registers you use in your function and follow the calling conventions we have discussed in the lecture. 3. Set up proper arguments to call the find max function 4. After your function returns, print out the following information. Three strings are already printed out in the template The function returned The maximum value is The address of the word is 5. Assume you need to implement find maxu, the unsigned version of find max. How can you do it quickly using your implementation of find max? You do not have to submit the code for find maxu. 6. Add good comments in your code

Explanation / Answer

The maximum value in the array can be found by using the following CODE:

.globl start

.data

array: .word   8,2,31,81,12,10

size:   .word   6

max:    .word 0

.text

main:

jal start

start:

lw $t3, size

la $t1, array

lw $s5, ($t1)     

add $t1, $t1, 4  

add $t3, $t3, -1      

loop:

lw $t4, ($t1)

ble $t4,$s5,L1

lw $s5, 0($t4)

#sw $s5,0($t1)

L1:

add $t3, $t3, -1            

addi $t1, $t1, 4

bnez $t3, loop

sw $s5, max

lw $a0, max

li $v0, 1

syscall

li $v0, 10

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