Question
Modify the following MIPS assembly program so that it has a menu and input/output looks like the example i/o. Currently the program asks the user
Modify the following MIPS assembly program so that it has a menu and input/output looks like the example i/o. Currently the program asks the user for values, it does this until the user enters a negative value. Insead of doing that it should only ask 10 times and store those values in an array. Currently the program automatically returns the min and max values as well as the average. These should instead be options in a menu. Intead of the average it should just return the sum and the product instead. Lastly a feature needs to be added, the user must be able to change the value based on its slot in the array. Here is what example i/o would look like with the user input in bold:
Please enter 10 integer values: 1 2 3 4 5 6 7 8 9 10 Your values are: 1 2 3 4 5 6 7 8 9 10 Menu (enter an int as your choice): 1) Replace an element at a certain position 2) Remove the max element 3) Remove the min element 4) Compute values and exit What would you like to do? 1 What position from the array do you wish to replace? 3 What value to you want to change it to? 4 Your values are: 1 2 4 4 5 6 7 8 9 10 Menu (enter an int as your choice): 1) Replace an element at a certain position 2) Remove the max element 3) Remove the min element 4) Compute values and exit What would you like to do? 2 Your values are: 1 2 4 4 5 6 7 8 9 Menu (enter an int as your choice): 1) Replace an element at a certain position 2) Remove the max element 3) Remove the min element 4) Compute values and exit What would you like to do? 4 The summation of all values in the array is: 46, the product of all values in the array is: 483840
Here is the current MIPs program:
.data txt1: .asciiz "Please enter apositive integer (negative integer to exit) : " txt2: .asciiz " The maximum value is : " txt3: .asciiz " The minimum value is : " txt4: .asciiz " The average is : " txt5: .asciiz " with remainder : "
.text .globl main main: addi $s0, $zero, 0 loop: la $a0, txt1 li $v0, 4 syscall li $v0, 5 syscall bltz $v0, average add $s0, $v0, 0 add $t0, $t0, 1 add $t3, $t3, $s0 beq $t0, 1, first blt $s0, $t1, min bgt $s0, $t2, max first: add $t1, $s0, 0 add $t2, $s0, 0 j loop min: add $t1, $s0, 0 j loop max: add $t2, $s0, 0 j loop
average: div $t3, $t0 mflo $t7 mfhi $t6 print: la $a0, txt2 li $v0, 4 syscall add $a0, $t2, 0 li $v0, 1 syscall la $a0, txt3 li $v0, 4 syscall add $a0, $t1, 0 li $v0, 1 syscall la $a0, txt4 li $v0, 4 syscall add $a0, $t7, 0 li $v0, 1 syscall exit: li $v0, 10 syscall
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started