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 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) {...}
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 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.
A. Write a program 1. Prompt the user to enter a positive integer n and read...
A. Write a program 1. Prompt the user to enter a positive integer n and read in the input. 2. Print out n of Z shape of size n X n side by side which made up of *. B. Write a C++ program that 1. Prompt user to enter an odd integer and read in the value to n. 2. Terminate the program if n is not odd. 3. Print out a cross shape of size n X n...
(1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in...
(1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the array's numbers on one line, each number followed by one space. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 142.0 Enter weight 4: 166.3 Enter weight 5: 93.0 You entered: 236.0 89.5 142.0 166.3 93.0 (2) Also output the total weight, by summing the array's elements. (1 pt) (3) Also output the...
1. Write a Java program that prompts the user to enter three integer numbers. Calculate and...
1. Write a Java program that prompts the user to enter three integer numbers. Calculate and print the average of the numbers. 2. Write a Java program that uses a for loop to print the odd numbers from 1 to 20. Print one number per line in the command line window. 3. Write a program which asks the user to input the size of potatoe fries she would like to purchase, and based on the size, it will tell her...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT