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
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
"This C Programming " Write a program that accepts four (4) lines of input: • The...
"This C Programming " Write a program that accepts four (4) lines of input: • The first line contains a float value in 4.2f format • The second line contains a char value • The third line contains a 4-digit int value • The fourth line contains a char value and then displays all of the input on a single line Write a program that accepts a phone number of the form +1(xxx)-xxx-xxxx where x is a digit, and displays...
***JAVA PROGRAM Write a method called shrink that accepts an array of integers (that the user...
***JAVA PROGRAM Write a method called shrink that accepts an array of integers (that the user inputs) as a parameter and returns a new array containing the result of replacing each pair of integers with the sum of that pair. For example, if an array called list stores the values {7, 2, 8, 9, 4, 15, 7, 1, 9, 10}, then the call of shrink(list) should return a new array containing {9, 17, 19, 8, 19}. The first pair from...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT