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)
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...
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...
java Problem 3: An Interesting Problem Write a program that accepts two positive integers: a deposited...
java Problem 3: An Interesting Problem Write a program that accepts two positive integers: a deposited amount of money and an interest rate, as an annual percentage rate. Your program will calculate the number of years that will take for the account balance to reach $1, 000,000. You can assume that the initial deposit is less than $1,000,000 Input The input will begin with a single line containing T , the number of test cases to follow. The remaining lines...
specifications for Tasks: 1. Write a program which accepts a list of integers which may contain...
specifications for Tasks: 1. Write a program which accepts a list of integers which may contain duplicated integers, and which outputs the input list as a sorted list in ascending order without duplication You can use either Ruby, C, C++, C# or Java to implement your program (referred to as P). 2. Design a test suite of 10 test cases (referred to as TC). Each test case has not more than 20 integers. 3. Test P against TC to make...
Write a program whose input is two integers, and whose output is the first integer and...
Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer. Ex: If the input is: -15 30 the output is: -15 -5 5 15 25 Ex: If the second integer is less than the first as in: 20 5 the output is: Second integer can't be less than the first. import java.util.Scanner; public class LabProgram {...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT