Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- B main
- array DEFW 25,10,13,9,44,15,6,2,36,42
- ALIGN
- main
- MOV R0,#0 ; array[R2]
- MOV R1,#0 ; array[R3]
- MOV R2,#0 ; current_index*4
- MOV R3,#0 ; (current_index+1)*4
- MOV R4,#9 ; array length-1
- MOV R5,#0 ; counter
- ; R6 could be used as a "sorted?" check but not required
- ADRL R7,array ; array address
- iloop CMP R4,#1
- BEQ iend
- MOV R2,#0
- MOV R3,#4
- jloop CMP R5,R4
- BEQ jend
- LDR R0,[R7,R2]
- LDR R1,[R7,R3]
- CMP R0,R1
- BGT no_swap
- STR R0,[R7,R3]
- STR R1,[R7,R2]
- no_swap ADD R2,R2,#4
- ADD R3,R3,#4
- ADD R5,R5,#1
- B jloop
- jend BL print
- SUB R4,R4,#1
- MOV R5,#0
- B iloop
- iend SWI 2
- print STMFD R13!, {R0-R7, R14}
- MOV R0,#0
- MOV R1,#0
- ADR R2,array
- ploop CMP R1,#40
- BEQ pend
- LDR R0,[R2,R1]
- SWI 4
- MOV R0,#44
- SWI 0
- ADD R1,R1,#4
- B ploop
- pend MOV R0,#13
- SWI 0
- LDMFD R13!, {R0-R7, PC}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement