Need to implement an IterativeMax function in assembly language using the MIPS calling convention.
IterativeMax take two arguments:
The address of an array of word-long (four byte) signed integers, held in $a0.
The length of the array as an unsigned integer, held in $a1.
The main purpose of the function is to determine which element of the provided array is the largest (i.e., the maximum element in the array). This is achieved by going through the array one element at a time. On each element, the function should do the following, in order:
1. Print out the current element of the array
2. Determine what the new maximal element of the array is so far. For example, if the old maximum was 5 and 7 was just observed in the array, then the maximum should be set to 7.
3. Print out the new maximum element of the array so far (after setting the new maximum in the previous step)
(code should work with any other valid (non-empty) array)
Please find the code below::
.data
A: .word 110,160,20,70,60,140,150, 80, 90,100, 10, 30,
40,120,130,50
size: .word 16 # lenqth of array A
max: .word 0
prompt: .asciiz " Current Element : "
prompt1: .asciiz " Maximum Element so far : "
prompt2: .asciiz " Maximum Element is : "
.text
la $a0,A #store address of A
lw $a1,size #store size of array
jal IterativeMax
sw $t6,max
li $v0,4
la $a0,prompt2 #it will print prompt
syscall
li $v0,1 #print max
lw $a0,max
syscall
li $v0,10 #Terminate execution
syscall
##################
IterativeMax:
li $s0,0
li $t6,0 #store max as 0
move $t7,$a0 #get array address
maxLoop:
mul $t0,$s0,4
add $t0,$t0,$t7
lw $t0,($t0)
li $v0,4
la $a0,prompt #it will print prompt
syscall
li $v0,1
move $a0,$t0
syscall
blt $t0,$t6,skipMax
move $t6,$t0 #store result in v0
skipMax:
li $v0,4
la $a0,prompt1 #it will print prompt
syscall
li $v0,1
move $a0,$t6
syscall
add $s0,$s0,1 #increament
blt $s0,$a1,maxLoop
jr $ra
output:

Need to implement an IterativeMax function in assembly language using the MIPS calling convention. IterativeMax take...
IN MIPS PLEASE. Need help writing a MIPS program that reads from a text file named "input.txt" and places it in a buffer. A buffer of 80 bytes is more than enough. Before you call your function, set $a0 equal to the address of the filename and $a1 to the address of the buffer where data is stored. The function should return the number of bytes read in $v0. In the main program, print an error message and terminate the...
Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...
How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...
Subroutines in MIPS Determines the minimum of two integers Functions within the MIPS slides describe how one can use subroutines (also called procedures, functions, and methods) in MIPS. Because of the importance of subroutines in modern programming, most hardware designers include mechanisms to help programmers. In a high-level language like C or Java, most of the details of subroutine calling are hidden from the programmer. MIPS has special registers to send information to and from a subroutine. The registers $a0,...
Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to track the number of Deer Hunting Licenses issued in a county and the state. It will display a menu with 5 choices numbered 1-5. They are (1) update the count, (2) display the number of licenses already issued to a county whose number is input, (3) display the county number and the number of licenses already issued to a range of counties whose starting...
daily21. Computing 1. C programming
Please provide comments and write pre-condition and
post-condition for the function.
Description Create a project called Daily21. Add a source file called daily21.c into the project. In this exercise, you will practice working with an array of integers. In the main function, you first need to create an integer array with 10 elements in t. Use a loop to read 10 integers from the user and store the values to the array (in the order...
Please help me with this in C# language. Returning an array from a function The goal for this exercise is to make sure that you return an array from a method (as a return value). Also: to give you more practice creating and using methods/functions. What you need to do for this exercise: In the starter project, add code to the Returning_An_Array class, so that the RunExercise method does the following: Declare an integer array variable, but DO NOT ALLOCATE...
I need help programming this question using C language. This program uses input data entered in command line at the same time when the command or .exe file is entered. They are called command-line arguments. Because everything entered in command line is taken as a string, these arguments including the command itself or the .exe file name are stored in an array of char pointers, each pointer points to the first character of a string (i.e., argument). The inputs can...
Hello I need help with this program. Should programmed in C!
Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...