2024-05-02 20:51:37 +00:00
|
|
|
MOV $0xFF0000,%SP
|
2024-05-03 06:09:57 +00:00
|
|
|
MOV $0x0000,%R0h
|
|
|
|
MOV $DATA,%R0l
|
2024-05-02 20:51:37 +00:00
|
|
|
PUSH %R0
|
2024-05-03 06:09:57 +00:00
|
|
|
MOV $DATA_END,%R0l
|
|
|
|
PUSH %R0
|
|
|
|
CALL $QUICKSORT
|
2024-05-02 20:51:37 +00:00
|
|
|
HALT
|
2024-05-03 06:09:57 +00:00
|
|
|
|
|
|
|
:QUICKSORT
|
|
|
|
#Get parameters from stack
|
|
|
|
MOV %SP,%R0
|
|
|
|
MOV $0x0000,%R1h
|
|
|
|
MOV $0x0004,%R1l
|
|
|
|
SUB %R1,%R0
|
|
|
|
SUB %R1,%R0
|
|
|
|
MOV (%R0),%R2
|
|
|
|
SUB %R1,%R0
|
|
|
|
MOV (%R0),%R3
|
|
|
|
|
|
|
|
#Compare input and quit if start >= end
|
|
|
|
CMP %R2,%R3
|
|
|
|
JMP,NS $BAIL
|
|
|
|
|
|
|
|
ADD %R2,%R3
|
|
|
|
|
|
|
|
:BAIL
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
|
|
|
:DATA
|
|
|
|
DDW $0x00000000
|
|
|
|
DDW $0x00000004
|
|
|
|
DDW $0x00000009
|
|
|
|
DDW $0x00000031
|
|
|
|
DDW $0x000000BB
|
|
|
|
DDW $0x0000000e
|
|
|
|
DDW $0x00000002
|
|
|
|
DDW $0x000000BB
|
|
|
|
DDW $0x01000000
|
|
|
|
:DATA_END
|
|
|
|
DDW $0xFFFFFFFF
|