In: Computer Science
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.
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:
