Compucolor.org – Virtual Media

Listing of file='SMSORT.BAS;01' on disk='vmedia/chip_53-sector.ccvf'

5 REM

CALL IN ASSEMBLY LANGUAGE SORT ROUTINE


10 PLOT 27,4:PRINT "RUN SMSORT":PLOT 27,27
20 CLEAR 20000
26 REM

SET UP TEXT ARRAY TO BE SORTED


30 DIM A$(100)
40 FOR X= 1TO 100
45 S$= ""
50 FOR L= 1TO RND (3)* 20:REM  LENGTH OF AN ITEM
60 S$= S$+ CHR$ (65+ 26* (RND (2)))
70 NEXT
76 A$(X)= S$
80 NEXT
85 REM

CALL SORT ROUTINE TO SORT A$


90 X= 128+ 256* ASC ("A")
95 PRINT "GOING TO SORT"
100 B= CALL (X)
105 REM

PRINT SORTED ARRAY, USING POINTERS AT LOC. B


110 DEF FN I(Z)= PEEK (Z)+ 256* PEEK (Z+ 1)
125 REM  STEP THRU POINTER ARRAY, EACH 2 BYTES LONG
130 FOR I= 2TO 2* 100STEP 2
140 IX= FN I(I+ B)
150 PRINT A$(IX):NEXT