Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .ORIG x3000
- LD R0, LIST
- AND R1, R1, #0 ; Array Pointer
- ADD R1, R1, #9 ; Length of Array - 1
- AND R2, R2, #0 ; Storage for Array
- AND R3, R3, #0 ; Storage for Array
- AND R4, R4, #0 ; Array Pointer
- LOOP LDR R2, R0, #0 ; Load first Array Element
- ADD R0, R0, #1 ; Increment Array Pointer
- LDR R3, R0, #0 ; Load second Array Element
- ADD R1, R1, #-1 ; Length of Array = Lenght of Array -1
- BRz LAST ; If this is the last Array Element, then branch
- NOT R4, R2
- ADD R5, R3, R4 ; R3 - R2 (In this case, the not is stored in R4)
- BRzp LOOP ; Branch back to loop if the result is 0 or above
- BRn FINW ; Branch to the Not in ascending order section - FINW
- LAST NOT R4, R2
- ADD R5, R3, R4 ; R3 - R2 (In this case, the not is stored in R4)
- BRp FINC ; If this final result is correct, branch to FINC
- FINW LD R0, LIST
- AND R1, R1, #0
- STR R1, R0, #-1
- BRnzp FIN ;Branch to end of program
- FINC LD R0, LIST
- AND R1, R1, #0
- ADD R1, R1, #1
- STR R1, R0, #-1
- FIN TRAP x25
- LIST .FILL x3101
- .END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement