Advertisement
Guest User

Untitled

a guest
Apr 15th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SPARK 1.07 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement