Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .text
  2.     #ori $4, $0, 30
  3.     #ori $5, $0, 25
  4.     #jal subroute
  5.     #ori $4, $0, 25
  6.     #ori $5, $0, 35
  7.     #jal subroute
  8.         #ori $4, $0, 210
  9.     #ori $5, $0, 28
  10.         #jal subroute
  11.         #ori $4, $0, 49
  12.         #ori $5, $0, 42
  13.         #jal subroute
  14.         ori $4, $0, 17
  15.         ori $5, $0, 3
  16.         jal subroute
  17.         #ori $4, $0, 17
  18.         #ori $5, $0, 51
  19.         #jal subroute
  20.     j exit #ends programm
  21. subroute:
  22.     or $2, $0, $5
  23.     beq $4, $0 end
  24. gt5: #start of the algorithm
  25.     beq $5, $0, gt9
  26.     slt $1, $5, $4 #r4 > r5
  27.     beq $1, $0, ins2
  28.     #if r4 > r5
  29.     sub $4, $4, $5# $4 <- $4 - $5
  30.     j gt5
  31. ins2: #else case
  32.     sub $5, $5, $4 # $5 <- $5 -$4
  33.     j gt5
  34.  
  35. avoidgt10:
  36.     j end #jump to end
  37.  
  38. gt9:
  39.     or $2, $4, $0
  40.  
  41.  
  42. end:
  43.     jr $ra
  44. exit:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement