Question

In: Computer Science

Write a complete MiniMIPS program that accepts a seqeunce of integers at input and after the...

Write a complete MiniMIPS program that accepts a seqeunce of integers at input and after the receipt of each new input value, displays the largest and smallest integers thus far.
An input of 0 indicates the end of input values and is not an input value itself.
Note that you do not need to keep all integers in memory.

Solutions

Expert Solution

Program:

.data
stmt: .asciiz "\nEnter a number: "
stmt1: .asciiz "maximum number: "
stmt2: .asciiz "\nminimum number: "
newline: .asciiz "\n"
.text
.globl main
main:
li $s0,0 #max = 0
li $s1,9999999 #initialize min 
li $t0,1 #number
loop: la $a0, stmt       # load address of stmt for syscall
      li $v0, 4           # specify Print String service
      syscall
      
      li $v0,5      #read integer
      syscall
      move $t0,$v0
      beqz $t0,end      
      bge $t0,$s0,updateMax
      ble $t0,$s1,updateMin
      j printVal
      
updateMax:      move $s0,$t0
               ble $t0,$s1,updateMin
               j printVal
updateMin:      move $s1,$t0
               j printVal
printVal:       la $a0, stmt1       # load address of stmt for syscall
                li $v0, 4           # specify Print String service
                syscall
                
                move $a0,$s0
                li $v0,1
                syscall    
                
                la $a0, stmt2       # load address of stmt for syscall
                li $v0, 4           # specify Print String service
                syscall
                
                move $a0,$s1
                li $v0,1
                syscall         
                  la $a0, newline       # load address of stmt for syscall
                li $v0, 4           # specify Print String service
                syscall
                j loop
end:   li $v0,10
       syscall

Output:


Related Solutions

Write a program that accepts a string and character as input, then counts and displays the...
Write a program that accepts a string and character as input, then counts and displays the number of times that character appears (in upper- or lowercase) in the string. Use C++ Enter a string: mallet Enter a character: a "A" appears 1 time(s) Enter a string: Racecar Enter a character: R "R" appears 2 time(s)
Write a program that first gets a list of integers from input. The input begins with...
Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain fewer than 20 integers. That list is followed by two more integers representing lower and upper bounds of a range. Your program should output all integers from the list that are within that range (inclusive of the bounds). For coding simplicity, follow each output integer by a space,...
Write a program that accepts as input the mass, in grams, and density, in grams per...
Write a program that accepts as input the mass, in grams, and density, in grams per cubic centimeters, and outputs the volume of the object using the formula: volume = mass / density. Format your output to two decimal places. ** Add Comments
PYTHON Write a program that accepts a range of input from the user and checks whether...
PYTHON Write a program that accepts a range of input from the user and checks whether the input data is sorted or not. If the data series is already sorted your program should print “True” or should print “False” otherwise. You should not use any sort function for this program. Input: How many numbers you want to input: 3 # user input 3 Input the number: 5 Input the number: 2 Input the number: 7 Output: False
2) Write a C++ program that accepts a sentence as an input from the user. Do...
2) Write a C++ program that accepts a sentence as an input from the user. Do the following with the sentence. Please use C++ style string for this question. 1) Count the number of letters in the input 2) Change all lower case letters of the sentence to the corresponding upper case
1. Specification Write a C program to implement a simple calculator that accepts input in the...
1. Specification Write a C program to implement a simple calculator that accepts input in the following format and displays the result of the computation: calc [operand_1] [operator] [operand_2] The operands operand_1 and operand_2 are non-negative integers. The operator is one of the following: addition (+), subtraction (-), multiplication (x), division (/) and modulo (%). Note: For the multiplication operator, use letter ‘x’. If you use the asterisk ‘*’, your program will not work properly 2. Implementation • The program...
C++ language Write a program that accepts as input the base price and the finished area...
C++ language Write a program that accepts as input the base price and the finished area in square feet of the three models. The program outputs the model(s) with the least price per square foot in the following format: If the colonial model is the least price, output: The price per square foot of the colonial model is the least. If the split-entry model is the least price, output: The price per square foot of the split-entry model is the...
Write a program, ArrayRange, that asks the user to input integers and that displays the difference...
Write a program, ArrayRange, that asks the user to input integers and that displays the difference between the largest and the smallest. You should ask the user the number of integers s/he would like to enter (this will allow you to set the length of the array). Allow the user to input all the numbers and then store them in the array. Search the array for the largest number, then search for the smallest, and finally compute the calculation. Display...
In C++, write a program that accepts a text file of ASCII words from standard input...
In C++, write a program that accepts a text file of ASCII words from standard input and store them and the amount of times the word appears in the file in a hash table using external chaining. Then print the words and their counts sorted based on alphabetical order and print them again in decreasing numerical order based on the amount of times the word appears in the file. Space, tab, and new line all count as space characters. The...
C Programming: Write a program that accepts 2 arguments, an input file and an output file....
C Programming: Write a program that accepts 2 arguments, an input file and an output file. The program is to store in the output file the contents of the input file in reverse. If the input file looks like this: Hello World.\n This is Line 2\n This is the end.\n then the output file should look like this: \n .dne eht si sihT\n 2 eniL si sihT\n .dlroW olleH The main program should look like this: int main(int argc, char...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT