Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BRA main
- main INP R0
- LDR R1, STARTARR
- PSH {R1}
- JMS readArr
- POP {R1}
- PSH {R1}
- JMS bsort
- POP {R1}
- JMS printArr
- HLT
- readArr MOV R2, #0
- loopRead CMP R2, R0
- BEQ doneRead
- INP R3
- STR R3, [R1]
- ADD R1, #1
- ADD R2, #1
- BRA loopRead
- doneRead RET
- printArr MOV R2, #0
- loopPrint CMP R2, R0
- BEQ donePrint
- LDR R3, [R1]
- OUT R3
- ADD R1, #1
- ADD R2, #1
- BRA loopPrint
- donePrint RET
- bsort MOV R3, #0//step
- bsfor1 MOV R7, R0
- SUB R7, #1
- CMP R3, R7
- BEQ bsdone
- MOV R4, #0//i
- bsfor2 PSH {R7}
- MOV R7, R0
- SUB R7, R3
- SUB R7, #1
- CMP R4, R7
- BEQ outfor2
- MOV R5, R1
- ADD R5, R4
- LDR R5, [R5]
- MOV R6, R1
- ADD R6, R4
- ADD R6, #1
- LDR R6, [R6]
- CMP R5, R6
- BLE noswap
- MOV R7, R1
- ADD R7, R4
- STR R6, [R7]
- ADD R7, #1
- STR R5, [R7]
- noswap POP {R7}
- ADD R4, #1
- BRA bsfor2
- outfor2 ADD R3, #1
- BRA bsfor1
- bsdone RET
- STARTARR DAT 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement