Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. Sort3Numbers: ;provide s0 (where to read numbers from)
  2. ADDIU sp, sp, -0x30
  3. SW t0, 0x0010 (sp)
  4. SW t1, 0x0014 (sp)
  5. SW t2, 0x0018 (sp)
  6. SW v0, 0x001C (sp)
  7. SW s0, 0x0020 (sp)
  8. SW ra, 0x0024 (sp)
  9. ;LUI s0, hi(ItemIDsChosen)
  10. ;ADDIU s0, s0, lo(ItemIDsChosen)
  11. LB t0, 0x0000 (s0) ;load item a
  12. LB t1, 0x0001 (s0) ;load item b
  13. LB t2, 0x0002 (s0) ;load item c
  14. SLT v0, t2, t0 ;if c is less than a, v0 = 1
  15. BNE v0, r0, swapCandA
  16. NOP
  17. afterCandA:
  18. LB t0, 0x0000 (s0)
  19. LB t1, 0x0001 (s0)
  20. LB t2, 0x0002 (s0)
  21. SLT v0, t1, t0, ;if b is less than a
  22. BNE v0, r0, swapAandB
  23. NOP
  24. afterAandB:
  25. LB t0, 0x0000 (s0)
  26. LB t1, 0x0001 (s0)
  27. LB t2, 0x0002 (s0)
  28. SLT v0, t2, t1 ;if c is less than b
  29. BNE v0, r0, swapBandC
  30. NOP
  31. afterBandC:
  32. LW t0, 0x0010 (sp)
  33. LW t1, 0x0014 (sp)
  34. LW t2, 0x0018 (sp)
  35. LW v0, 0x001C (sp)
  36. LW s0, 0x0020 (sp)
  37. LW ra, 0x0024 (sp)
  38. JR RA
  39. ADDIU sp, sp, 0x30
  40. swapCandA:
  41. SB t0, 0x0002 (s0)
  42. BEQ r0, r0, afterCandA
  43. SB t2, 0x0000 (s0)
  44. swapAandB:
  45. SB t0, 0x0001 (s0)
  46. BEQ r0, r0, afterAandB
  47. SB t1, 0x0000 (s0)
  48. swapBandC:
  49. SB t1, 0x0002 (s0)
  50. BEQ r0, r0, afterBandC
  51. SB t2, 0x0001 (s0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement