Advertisement
Guest User

arma1

a guest
Jan 22nd, 2020
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 0.88 KB | None | 0 0
  1. ENTRY
  2.     B main
  3.     ;;  array   DEFW    4, 15, 47, 23, 18, 10, 22, 6, 37, 28
  4.  
  5. array   DEFW    8, 4, 17, 23, 40, 43, 35, 21, 4, 34
  6.    
  7. message DEFB    "Sorted list is \0"
  8. msg2    DEFB    " made up of \0"
  9. msg3    DEFB    " and \0"
  10. msg4    DEFB    "\n\0"
  11.     ALIGN
  12.  
  13. main    LDR R0,array
  14.         SUB R1,R0,#4
  15.  
  16.         MOV R4,#1
  17.         B iLoopCond
  18. iLoop   LDR R6, [R0, R4 LSL #2]
  19.         MOV R5,R4               ; j is in r5
  20.  
  21.         B cLoopCond
  22.  
  23. cLoop   STR R7, [r0, r5 LSL #3]
  24.         sub r5,r5,#4
  25.  
  26. cLoopCond
  27.         CMP R5, #0
  28.         BLE cLoopEnd
  29.         LDR R7, [R1, R5 LSL #2]
  30.         CMP R7, R6
  31.         BGT cLoop
  32.  
  33. cLoopEnd
  34.         STR R6,[R0, R4 LSL #2]
  35.  
  36. iLoopCond
  37.         CMP R4,#10
  38.         BLT iLoop
  39.  
  40.         ADR R0, message
  41.         SWI 3
  42.  
  43.         ADR R0, array
  44.         MOV R1, #10
  45.         BL PrintArray
  46.  
  47.         ADR R0,msg4
  48.         SWI 3
  49.  
  50.  
  51.         SWI 2
  52.  
  53.  
  54. PrintArray
  55.         MOV R3,R0
  56.         B   ploopCond
  57. ploop   LDR R0, [R3], #4
  58.         SWI 4
  59.         MOV R0,#','
  60.         SWI 0
  61.         SUB R1,R1,#1
  62. ploopCond
  63.         CMP R1,#0
  64.         BGT ploop
  65.         MOV PC,R14
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement