Question

In: Computer Science

Write a mips program that would function in QTSPIM that asks the user to enter a...

Write a mips program that would function in QTSPIM that asks the user to enter a list of integer values, one per line, with the last value being a negative. The program should read in these integers until a negative number is entered. Afterwards the program should print 1) sum, 2) minimum value, 3) max value, 4) mean and 5) variance value. of the numbers that were entered.

Solutions

Expert Solution

ANSWER:

ScreenShot

--------------------------------------------------------------------------

Program

#Variable declaration
.data
list: .asciiz "Please enter values into the list:\n"
sList: .asciiz "Sum="
minList: .asciiz "\nMinValue="
maxList: .asciiz "\nMaxValue="
meanList: .asciiz "\nMeanValue="
varianceList: .asciiz "\nVarianceValue="
#Main program
.globl main
.text
main:
#Prompt user to enter list values
la $a0,list
li $v0,4
syscall
#Read values
li $v0,5
syscall
#For sum
li $s0,0
#for sum of squares
li $s3,0
#for counter
li $t0,0
#for min value
move $s1,$v0
#for max value
move $s2,$v0
#lsit enter loop until negative number enter
loop:
blt $v0,0,disp
#sum of all numbers
add $s0,$s0,$v0
#number of elements in the list
addi $t0,$t0,1
#Comparison for min number
bgt $s1,$v0,small
loop1:
#Comparison for max number
blt $s2,$v0,large
loop2:
#sum of each elements square sum
mul $v0,$v0,$v0
add $s3,$s3,$v0
#read next value
li $v0,5
syscall
#continue loop
j loop
#min value setting
small:
move $s1,$v0
j loop1
#max value setting
large:
move $s2,$v0
j loop2
#display values
disp:
#sum of the list elements display
la $a0,sList
li $v0,4
syscall
move $a0,$s0
li $v0,1
syscall
#min of the list elements display
la $a0,minList
li $v0,4
syscall
move $a0,$s1
li $v0,1
syscall
#max of the list elements display
la $a0,maxList
li $v0,4
syscall
move $a0,$s2
li $v0,1
syscall
#mean of the list elements display
la $a0,meanList
li $v0,4
syscall
#sum/N
div $t1,$s0,$t0
move $a0,$t1
li $v0,1
syscall
#variance of the list elements display
la $a0,varianceList
li $v0,4
syscall
#sigma(x^2/N)
div $t2,$s3,$t0
#Mean^2
mul $t1,$t1,$t1
#sigma(x^2/N)-Mean^2
sub $t2,$t2,$t1
move $a0,$t2
li $v0,1
syscall
#end of the program
exit:
li $v0,10
syscall

----------------------------------------------------------

Output

Please enter values into the list:
10
14
23
4
-5
Sum=51
MinValue=4
MaxValue=23
MeanValue=12
VarianceValue=66

If you do not get anything in this solution ,please put a comment and i will help you out .

Do not give a downvote instantly.It is a humble request.

If you like my answer,please give an upvote.....Thank you.


Related Solutions

Write a mips assembly language program that asks the user to enter an unsigned number and...
Write a mips assembly language program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6.
Write a mips assembly language program that asks the user to enter an alphabetic character (either...
Write a mips assembly language program that asks the user to enter an alphabetic character (either lower or upper case)and change the case of the character from lower to upper and from upper to lower and display it.
Write a program that asks the user to enter the name of a file, and then...
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad or another text editor to create a sample file that can be used to test the program. Sample Run java FileLetterCounter Enter file name: wc4↵ Enter character to count: 0↵ The character '0' appears in the file...
Write a MIPS program that asks the user for 2 numbers. Output the sum of the...
Write a MIPS program that asks the user for 2 numbers. Output the sum of the 2 numbers. The difference between the 2 numbers (num1-num2) and (num2-num1) The value that is 305 more than the 1st number. The value that is 305 less than the 2nd number
Program should be written in Java a) Write a program that asks the user to enter...
Program should be written in Java a) Write a program that asks the user to enter the approximate current population of India. You should have the computer output a prompt and then YOU (as the user should enter the population.)  For testing purposes you may use the value of 1,382,000,000 from August 2020. Assume that the growth rate is 1.1% per year. Predict and print the predicted population for 2021 and 2022. The printout should include the year and the estimated...
Write a MIPS program that will ask the user to enter two numbers at the console...
Write a MIPS program that will ask the user to enter two numbers at the console and pass the values to a function that does multiplication
Write a Java program that asks the user to enter an integer that is used to...
Write a Java program that asks the user to enter an integer that is used to set a limit that will generate the following four patterns of multiples of five using nested loops •Ascending multiples of five with ascending length triangle •Ascending multiples of five with descending length (inverted) triangle •Descending multiples of five with ascending length triangle •Descending multiples of five with descending length (inverted) triangle Use error checking to keep asking the user for a positive number until...
In Python write a program that asks the user to enter the monthly costs for the...
In Python write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance the program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. your program MUST have BOTH a main function AND a function named calcExpenses to calculate the expenses. DO NOT display the expenses inside of the calcExpenses function!!...
Write a program that asks the user to enter an unsigned number and read it. Then...
Write a program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6. COMMENT COMPLETE CODE PLEASE
In a file called LengthSum.java, write a program that: - Asks the user to enter a...
In a file called LengthSum.java, write a program that: - Asks the user to enter a string. - Asks the user to enter a second string. - Prints out the length of the first string, the length of the second string, and the sum of the two lengths, using EXACTLY the same format as shown below. For example: if the user enters strings "UT" and "Arlington", your program output should look EXACTLY like this: Please enter a string: UT Please...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT