SHARE
TWEET

Untitled

a guest Oct 18th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2.     str1: .asciiz "Enter the first integer: "
  3.     str2: .asciiz "Enter the second integer: "
  4.     msg1: .asciiz "The greater number is number "
  5.     msg2: .asciiz "The smaller number is number "
  6.     msg3: .asciiz "The two numbers are not equal!\n"
  7.     msg4: .asciiz "The two numbers are equal!\n"
  8.     msg5: .asciiz "\n"
  9. .text
  10. .globl main
  11.     main:
  12.         la $a0, str1                          # Print str1
  13.         li $v0, 4                                      
  14.         syscall
  15.         li $v0, 5           # Read integer1
  16.         syscall
  17.  
  18.         move $t0, $v0       # t0 = integer1
  19.        
  20.         la $a0, str2            # Print str2
  21.         li $v0, 4
  22.         syscall
  23.         li $v0, 5           # Read integer2
  24.         syscall
  25.         move $t1, $v0       # t1 = integer2
  26.        
  27.         beq $t0, $t1, equal     # if (integer1 == integer2) go to label equal
  28.         la $a0, msg3            # Print msg3
  29.         li $v0, 4
  30.         syscall
  31.        
  32.         bge $t0, $t1, greater   # if (integer1 > integer2) go to label integer1
  33.         move $t2, $t0           # t3 = t1
  34.         move $t0, $t1           # t1 = t2
  35.         move $t1, $t2           # t2 = t3 (swap)
  36.         j greater               # avoid notequal
  37.        
  38.     equal:
  39.         la $a0, msg4            # Print msg4
  40.         li $v0, 4
  41.         syscall
  42.        
  43.     greater:
  44.         la $a0, msg1            # Print msg1
  45.         li $v0, 4
  46.         syscall
  47.         move $a0, $t0           # a0 = t0
  48.         li $v0, 1               # Print integer1
  49.         syscall
  50.         la $a0, msg5            # Print msg5
  51.         li $v0, 4
  52.         syscall
  53.         la $a0, msg2            # Print msg2
  54.         li $v0, 4
  55.         syscall
  56.         move $a0, $t1           # a0 = t1
  57.         li $v0, 1               # Print integer2
  58.         syscall
  59.        
  60.     endz:
  61.         jr $ra
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top