Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. B main
  2.  
  3. array DEFW 25,10,13,9,44,15,6,2,36,4
  4.  
  5. ALIGN
  6. main
  7. MOV R0,#0 ; array[R2]
  8. MOV R1,#0 ; array[R3]
  9. MOV R2,#0 ; current_index*4
  10. MOV R3,#0 ; (current_index+1)*4
  11.  
  12. MOV R4,#8 ; array length-2
  13. MOV R5,#0 ; counter
  14. MOV R6,#0 ; sorted?
  15. ADRL R7,array ; array address
  16.  
  17. iloop CMP R4,#0
  18. BEQ iend
  19.  
  20. MOV R2,#0
  21. MOV R3,#4
  22.  
  23. jloop CMP R5,R4
  24. BEQ jend
  25.  
  26. LDR R0,[R7,R2]
  27. LDR R1,[R7,R3]
  28.  
  29. CMP R0,R1
  30. BLT no_swap
  31.  
  32. STR R0,[R7,R3]
  33. STR R1,[R7,R2]
  34.  
  35. no_swap ADD R2,R2,#4
  36. ADD R3,R3,#4
  37. ADD R5,R5,#1
  38.  
  39. jend SUB R4,R4,#1
  40. B iloop
  41.  
  42. iend MOV R4,#10
  43. MOV R9,#0
  44. print CMP R4,#0
  45. BEQ end
  46. LDR R0,[R7,R9]
  47. SWI 4
  48. MOV R0,#44
  49. SWI 0
  50. ADD R9,R9,#4
  51. SUB R4,R4,#1
  52. B print
  53.  
  54. end SWI 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement