Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. cmp $1,0
  2. bab >have_data
  3.  
  4. @have_data:
  5. mov $4, $0
  6. add $5, $4, $1
  7. loa $6, $4
  8.  
  9. sub $3, $4, $0
  10.  
  11. add $4, $4, $3
  12. cmp $4, $5
  13. bbw >max_scan_loop
  14. jmp >done
  15. @max_scan_loop:
  16. loa $7, $4 # load current data item
  17. cmp $7, $6 # compare current with candidate maximum
  18. bae >no_update # ... if current <= candidate, no update
  19. mov $6, $7 # ... update candidate maximum
  20. sub $3, $4, $0 # ... and its position
  21. @no_update:
  22. add $4, $4, 1 # advance current address
  23. cmp $4, $5 # compare current address with last address
  24. bbw >max_scan_loop
  25. @done:
  26. cmp $1,0
  27. bab >have_data2
  28.  
  29. @have_data2:
  30. mov $4, $0
  31. add $5, $4, $1
  32. loa $2, $4
  33.  
  34. sub $3, $4, $0
  35.  
  36. add $4, $4, 3
  37. cmp $4, $5
  38. bbw >min_scan_loop
  39. jmp >done2
  40. @min_scan_loop:
  41. loa $7, $4 # load current data item
  42. cmp $2, $7 # compare current with candidate maximum
  43. bae >no_update2 # ... if current <= candidate, no update
  44. mov $2, $7 # ... update candidate maximum
  45. sub $3, $4, $0 # ... and its position
  46. @no_update2:
  47. add $4, $4, 1 # advance current address
  48. cmp $4, $5 # compare current address with last address
  49. bbw >min_scan_loop
  50. @done2:
  51. sub $2, $2, $6
  52. mov $3, 0
  53. mov $4, 0
  54. mov $5, 0
  55. mov $6, 0
  56. mov $7, 0
  57. hlt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement