Question

In: Computer Science

Prompt user to enter 2 integer numbers from console, compare and display these 2 numbers from...

Prompt user to enter 2 integer numbers from console, compare and display these 2 numbers from small to great.

This is required to be done in MIPS assembly language.

Solutions

Expert Solution

compareTwoNumbers.asm:

.data
str1 : .asciiz "enter the 1st integer: "
str2 : .asciiz "enter the 2nd integer: "
str3 : .asciiz "The 1st num is bigger.\n"
str4 : .asciiz "The 2nd num is bigger.\n"
str5 : .asciiz "Two numbers are equal.\n"
space: .asciiz " "
.text
main:
     li $v0, 4
     la $a0, str1 #input prompt 1
     syscall

     li $v0,5 # read 1st number
     syscall
     move $t0, $v0

     li $v0,4
     la $a0, str2 #input prompt 2
     syscall

     li $v0,5 # read 2nd number
     syscall
     move $t1, $v0

     bgt $t0,$t1,a
     bgt $t1,$t0,b

     li $v0,4
     la $a0, str5
     syscall
     
     li $v0,1
     move $a0,$t0
     syscall
     
     li $v0,4
     la $a0, space
     syscall
     
     li $v0,1
     move $a0,$t1
     syscall
     
     j end
a:
     li $v0,4
     la $a0, str3
     syscall
     
     li $v0,1
     move $a0,$t1
     syscall
     
     li $v0,4
     la $a0, space
     syscall
     
     li $v0,1
     move $a0,$t0
     syscall
     
     j end

b:
     li $v0,4
     la $a0, str4
     syscall
     
     li $v0,1
     move $a0,$t0
     syscall
     
     li $v0,4
     la $a0, space
     syscall
     
     li $v0,1
     move $a0,$t1
     syscall
     
     j end
end: li $v0,10
     syscall

Output:


Related Solutions

Prompt user to enter an integer number from console. Use 2 methods to multiply this number...
Prompt user to enter an integer number from console. Use 2 methods to multiply this number by factor 7, display result. This is required to be done in MIPS Assembly Language.
Prompt user to enter an integer number from console. Use 2 methods to multiply this number...
Prompt user to enter an integer number from console. Use 2 methods to multiply this number by factor 7, display result. This is required to be done in MIPS Assembly Language.
Prompt the user to enter an integer Then, prompt the user to enter a positive integer...
Prompt the user to enter an integer Then, prompt the user to enter a positive integer n2. Print out all the numbers that are entered after the last occurrence of n1 and whether each one is even or odd If n1 does not occur or there are no values after the last occurrence of n1, print out the message as indicated in the sample runs below. Sample: Enter n1: -2 Enter n2: 7 Enter 7 values: -2 3 3 -2...
Prompt user to enter an integer number from console. Use 3 methods to check if this...
Prompt user to enter an integer number from console. Use 3 methods to check if this number is even or odd. Display result. This is required to be done in MIPS assembly language.
JAVA Programming Implement the class DataProcess and prompt a user to enter 5 integer numbers. Once...
JAVA Programming Implement the class DataProcess and prompt a user to enter 5 integer numbers. Once The program should output the average, largest, and smallest of 5 numbers. You must implement the methods listed below in your program. static float getAverage(int[] data) {...} static int getLargest(int[] data) {...} static int getSmallest(int[] data) {...}
4. Prompt user to enter a double number from console. Round this number so it will...
4. Prompt user to enter a double number from console. Round this number so it will keep 2 places after the decimal point. Display new number. For example, number 12.3579 will round to 12.36; number 12.4321 will round to 12.43 This is meant to be written in Java 14.0
Input from console 3 double numbers, compare these 3 numbers and display them from small to...
Input from console 3 double numbers, compare these 3 numbers and display them from small to great. In Java Please
Write a C program that prompt the user to enter 10 numbers andstores the numbers...
Write a C program that prompt the user to enter 10 numbers and stores the numbers in an array. Write a function, smallestIndex, that takes as parameters an int array and its size and return the index of the first occurrence of the smallest element in the array.The main function should print the smallest number and the index of the smallest number.
Write a C++ program that prompt the user to enter 10 numbers andstores the numbers...
Write a C++ program that prompt the user to enter 10 numbers and stores the numbers in an array. Write a function, smallestIndex, that takes as parameters an int array and its size and return the index of the first occurrence of the smallest element in the array.The main function should print the smallest number and the index of the smallest number.
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT