Advertisement
Guest User

sorted

a guest
Nov 18th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. .ORIG x3000
  2. LD R0, LIST
  3. AND R1, R1, #0 ; Array Pointer
  4. ADD R1, R1, #9 ; Length of Array - 1
  5. AND R2, R2, #0 ; Storage for Array
  6. AND R3, R3, #0 ; Storage for Array
  7. AND R4, R4, #0 ; Array Pointer
  8. LOOP LDR R2, R0, #0 ; Load first Array Element
  9. ADD R0, R0, #1 ; Increment Array Pointer
  10. LDR R3, R0, #0 ; Load second Array Element
  11. ADD R1, R1, #-1 ; Length of Array = Lenght of Array -1
  12. BRz LAST ; If this is the last Array Element, then branch
  13. NOT R4, R2
  14. ADD R5, R3, R4 ; R3 - R2 (In this case, the not is stored in R4)
  15. BRzp LOOP ; Branch back to loop if the result is 0 or above
  16. BRn FINW ; Branch to the Not in ascending order section - FINW
  17. LAST NOT R4, R2
  18. ADD R5, R3, R4 ; R3 - R2 (In this case, the not is stored in R4)
  19. BRp FINC ; If this final result is correct, branch to FINC
  20. FINW LD R0, LIST
  21. AND R1, R1, #0
  22. STR R1, R0, #-1
  23. BRnzp FIN ;Branch to end of program
  24. FINC LD R0, LIST
  25. AND R1, R1, #0
  26. ADD R1, R1, #1
  27. STR R1, R0, #-1
  28. FIN TRAP x25
  29. LIST .FILL x3101
  30. .END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement