Advertisement
Guest User

Untitled

a guest
Apr 15th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SPARK 1.76 KB | None | 0 0
  1. #Robert Entenmann
  2. #04/15/2018
  3. #Find Minimum and Maximum of 4 numbers
  4.  
  5. .data
  6.     Num1:       .word       0
  7.     Num2:       .word       0
  8.     Num3:       .word       0
  9.     Num4:       .word       0
  10.     Min1:       .word       0
  11.     Max1:       .word       0
  12.     Min2:       .word       0
  13.     Max2:       .word       0
  14.     Min3:       .word       0
  15.     Max3:       .word       0
  16.    
  17.     msg1:       .asciiz     "Please input a number: "
  18.     msg2:       .asciiz     "Please input a number: "
  19.     msg3:       .asciiz     "The maximum of the four numbers is "
  20.     msg4:       .asciiz     "The minimum of the four numbers is "
  21.  
  22.    
  23. .text
  24. .globl  main            #Start of main
  25. .ent    main
  26. main:
  27.  
  28.     jal readtwo
  29.     sw $t0, Num1
  30.     sw $t1, Num2
  31.    
  32.     jal findminmax
  33.     sw $t2, Min1
  34.     sw $t3, Max1
  35.    
  36.     jal readtwo
  37.     sw $t0, Num3
  38.     sw $t1, Num4
  39.    
  40.     jal findminmax
  41.     sw $t2, Min2
  42.     sw $t3, Max2
  43.    
  44.     jal findminmax
  45.     sw $t2, Min3
  46.     sw $t3, Max3
  47.    
  48.     li $v0, 4          
  49.     la $a0, msg3
  50.     syscall
  51.    
  52.     lw $a0, Max3
  53.     li $v0, 1
  54.     syscall
  55.    
  56.     li $v0, 4
  57.     la $a0, msg4
  58.     syscall
  59.    
  60.     lw $a0, Min3
  61.     li $v0, 1
  62.     syscall
  63.    
  64. .end    main            #End of main
  65.  
  66.  
  67. .globl  readtwo         #Start of readtwo function
  68. .ent    readtwo
  69. readtwo:
  70.  
  71.     li $v0, 4           #prompts user to input a number
  72.     la $a0, msg1
  73.     syscall
  74.    
  75.     li $v0, 5           #Gets users input
  76.     syscall
  77.     move $t0, $v0
  78.    
  79.     li $v0, 4           #prompts user to input a second number
  80.     la $a0, msg2
  81.     syscall
  82.    
  83.     li $v0, 5           #Gets users second input
  84.     syscall
  85.     move $t1, $v0
  86.    
  87.     jr $ra
  88.  
  89. .end    readtwo         #End of readtwo function
  90.  
  91.  
  92. .globl  findminmax      #Start of findminmax function
  93. .ent    findminmax
  94. findminmax:
  95.    
  96.     bgt $t3, $t0, $t1
  97.     blt $t2, $t0, $t1
  98.    
  99.     jr $ra
  100.  
  101. .end    findminmax      #End of findminmax function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement