Home » Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_24.ADF » P/ABC-F

P/ABC-F

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_24.ADF
Filename: P/ABC-F
Read OK:
File size: 0C61 bytes
Load address: 1900
Exec address: FFFF8023
Duplicates

There is 1 duplicate copy of this file in the archive:

File contents
   10 REM Machine code alphasort from book ISBN 0003831507
   20 REM Works by comparing big chunks at once so that they are roughly in order,then sorting them a bit finer  and a bit finer - hence the name diminishing increment sort
   30NUMBER=&70:POINTER1=&72:POWER=&74
   40POINTER2=&75:SIZE=&77:LOOPCOUNT=&79:FLAG=&7B:STORE=&7C:CYCLES=&7E
   50string1=&80:string2=&82:length1=&84:length2=&85
   60DIM SORT 500
   70FOR PASS=0 TO 2 STEP 2
   80P%=SORT
   90[OPT PASS
  100LDA &0601
  110STA STORE
  120LDA &0602
  130STA STORE+1
  140LDY #0
  150STY SIZE+1
  160STY POWER
  170LDA (STORE),Y
  180STA NUMBER
  190INY
  200STY SIZE
  210LDA (STORE),Y
  220STA NUMBER+1
  230.SIZELOOP
  240INC POWER
  250ASL SIZE
  260ROL SIZE+1
  270SEC
  280LDA SIZE
  290SBC NUMBER
  300LDA SIZE+1
  310SBC NUMBER+1
  320BCC SIZELOOP
  330.OUTERLOOP
  340LSR SIZE+1
  350ROR SIZE
  360SEC
  370LDA NUMBER
  380SBC SIZE
  390STA CYCLES
  400LDA NUMBER+1
  410SBC SIZE+1
  420STA CYCLES+1
  430.MIDLOOP
  440LDA #0
  450STA FLAG
  460STA LOOPCOUNT
  470STA LOOPCOUNT+1
  480LDA &0604
  490STA POINTER1
  500LDA &0605
  510STA POINTER1+1
  520LDA SIZE+1
  530STA STORE+1
  540LDA SIZE
  550ASL A
  560ROL STORE+1
  570ASL A
  580ROL STORE+1
  590CLC
  600ADC POINTER1
  610STA POINTER2
  620LDAPOINTER1+1
  630ADC STORE+1
  640STA POINTER2+1
  650.INNERLOOP
  660LDY #0
  670LDA (POINTER1),Y
  680STA string1
  690LDA (POINTER2),Y
  700STA string2
  710INY
  720LDA (POINTER1),Y
  730STA string1+1
  740LDA (POINTER2),Y
  750STA string2+1
  760LDY #3
  770LDA (POINTER1),Y
  780STA length1
  790LDA (POINTER2),Y
  800STA length2
  810LDY #0
  820.COMPLOOP
  830LDA (string2),Y
  840CMP (string1),Y 
  850BCC SWOP
  860BNE NOSWOP
  870INY
  880CPY length1
  890BEQ NOSWOP
  900CPY length2
  910BEQ SWOP
  920BNE COMPLOOP
  930.STAGE1
  940BNE MIDLOOP
  950.STAGE2
  960BNE OUTERLOOP
  970.SWOP
  980LDY #3
  990STY FLAG
 1000.SWOPLOOP
 1010LDA (POINTER1),Y
 1020TAX
 1030LDA (POINTER2),Y
 1040STA (POINTER1),Y
 1050TXA
 1060STA (POINTER2),Y
 1070DEY
 1080BPL SWOPLOOP
 1090.NOSWOP
 1100INC LOOPCOUNT
 1110BNE SKIP
 1120INC LOOPCOUNT+1
 1130.SKIP
 1140LDA POINTER1
 1150CLC
 1160ADC #4
 1170STA POINTER1
 1180BCC SKIP2
 1190INC POINTER1+1
 1200.SKIP2
 1210LDA POINTER2
 1220CLC
 1230ADC #4
 1240STA POINTER2
 1250BCC SKIP3
 1260INC POINTER2+1
 1270.SKIP3
 1280LDA CYCLES
 1290CMP LOOPCOUNT
 1300BNE INNERLOOP
 1310LDA CYCLES+1
 1320CMP LOOPCOUNT+1
 1330BNE INNERLOOP
 1340LDA FLAG
 1350BEQ FLAGCLEAR
 1360SEC
 1370LDA CYCLES
 1380SBC #1
 1390STA CYCLES
 1400BCS SKIP4
 1410DEC CYCLES+1
 1420LDA CYCLES
 1430.SKIP4
 1440BNE STAGE1
 1450LDA CYCLES+1
 1460BNE STAGE1
 1470.FLAGCLEAR
 1480DEC POWER
 1490BNE STAGE2
 1500 RTS:]
 1510NEXT PASS
 1520 REM Basic from here onwards is your program that uses the above sorter
 1530 CLS
 1540INPUT"NUMBER OF STRINGS ";NUMBER%
 1550  IF NUMBER%>1000 THEN PRINT"TOO MANY":GOTO 1540:REM Alters depending on screen mode
 1560 PRINT
 1570 DIM ARRAY$(NUMBER%)
 1580 REM Randomly generates 10 letter strings
 1590 PRINT:PRINT"STRINGS ARE...":PRINT
 1600 FOR N%=1 TO NUMBER%
 1610 string$=""
 1620 FOR Z%=1 TO RND(10)
 1630 K$=CHR$(RND(26)+64)
 1640 string$=string$+K$
 1650 NEXT Z%
 1660 ARRAY$(N%)=string$
 1670 PRINT ARRAY$(N%)
 1680 NEXT N%
 1690 PRINT:PRINT"NOW SORTING..."
 1700 REM Turn timer on,note that variable names must be the same as used in the code
 1710 HERE%=TIME
 1720 CALL SORT,NUMBER%,ARRAY$(1)
 1730 NOW%=TIME
 1740 FOR N%=1 TO NUMBER%
 1750 PRINT ARRAY$(N%)
 1760 NEXT N%
 1770 PRINT:PRINT"SORTED ";NUMBER%;" ITEMS IN ";(NOW%-HERE%)/100;" SECONDS"
 1780 REM Time @ 10 lttrs: 1700=21s ; 400=2.2s ; 100=0.24s

7 � Machine code alphasort from book ISBN 0003831507
� � Works by comparing big chunks at once so that they are roughly in order,then sorting them a bit finer  and a bit finer - hence the name diminishing increment sort
%NUMBER=&70:POINTER1=&72:POWER=&74
(EPOINTER2=&75:SIZE=&77:LOOPCOUNT=&79:FLAG=&7B:STORE=&7C:CYCLES=&7E
23string1=&80:string2=&82:length1=&84:length2=&85
<� SORT 500
F� PASS=0 � 2 � 2
PP%=SORT
Z
[OPT PASS
d
LDA &0601
n
STA STORE
x
LDA &0602
�STA STORE+1
�
LDY #0
�STY SIZE+1
�
STY POWER
�LDA (STORE),Y
�STA NUMBER
�INY
�STY SIZE
�LDA (STORE),Y
�STA NUMBER+1
�
.SIZELOOP
�
INC POWER
�ASL SIZE
ROL SIZE+1
SEC
LDA SIZE
"SBC NUMBER
,LDA SIZE+1
6SBC NUMBER+1
@BCC SIZELOOP
J.OUTERLOOP
TLSR SIZE+1
^ROR SIZE
hSEC
rLDA NUMBER
|SBC SIZE
�STA CYCLES
�LDA NUMBER+1
�SBC SIZE+1
�STA CYCLES+1
�.MIDLOOP
�
LDA #0
�STA FLAG
�STA LOOPCOUNT
�STA LOOPCOUNT+1
�
LDA &0604
�STA POINTER1
�
LDA &0605
�STA POINTER1+1
LDA SIZE+1
STA STORE+1
LDA SIZE
&	ASL A
0ROL STORE+1
:	ASL A
DROL STORE+1
NCLC
XADC POINTER1
bSTA POINTER2
lLDAPOINTER1+1
vADC STORE+1
�STA POINTER2+1
�.INNERLOOP
�
LDY #0
�LDA (POINTER1),Y
�STA string1
�LDA (POINTER2),Y
�STA string2
�INY
�LDA (POINTER1),Y
�STA string1+1
�LDA (POINTER2),Y
�STA string2+1
�
LDY #3
LDA (POINTER1),Y
STA length1
LDA (POINTER2),Y
 STA length2
*
LDY #0
4
.COMPLOOP
>LDA (string2),Y
HCMP (string1),Y 
RBCC SWOP
\BNE NOSWOP
fINY
pCPY length1
zBEQ NOSWOP
�CPY length2
�BEQ SWOP
�BNE COMPLOOP
�.STAGE1
�BNE MIDLOOP
�.STAGE2
�BNE OUTERLOOP
�	.SWOP
�
LDY #3
�STY FLAG
�
.SWOPLOOP
�LDA (POINTER1),Y
�TAX
LDA (POINTER2),Y
STA (POINTER1),Y
TXA
$STA (POINTER2),Y
.DEY
8BPL SWOPLOOP
B.NOSWOP
LINC LOOPCOUNT
VBNE SKIP
`INC LOOPCOUNT+1
j	.SKIP
tLDA POINTER1
~CLC
�
ADC #4
�STA POINTER1
�
BCC SKIP2
�INC POINTER1+1
�
.SKIP2
�LDA POINTER2
�CLC
�
ADC #4
�STA POINTER2
�
BCC SKIP3
�INC POINTER2+1
�
.SKIP3
LDA CYCLES

CMP LOOPCOUNT
BNE INNERLOOP
LDA CYCLES+1
(CMP LOOPCOUNT+1
2BNE INNERLOOP
<LDA FLAG
FBEQ FLAGCLEAR
PSEC
ZLDA CYCLES
d
SBC #1
nSTA CYCLES
x
BCS SKIP4
�DEC CYCLES+1
�LDA CYCLES
�
.SKIP4
�BNE STAGE1
�LDA CYCLES+1
�BNE STAGE1
�.FLAGCLEAR
�
DEC POWER
�BNE STAGE2
�
 RTS:]
�
� PASS
�I � Basic from here onwards is your program that uses the above sorter
� �
!�"NUMBER OF STRINGS ";NUMBER%
K  � NUMBER%>1000 � �"TOO MANY":� �TDF:� Alters depending on screen mode
 �
" � ARRAY$(NUMBER%)
,+ � Randomly generates 10 letter strings
6 �:�"STRINGS ARE...":�
@ � N%=1 � NUMBER%
J string$=""
T � Z%=1 � �(10)
^ K$=�(�(26)+64)
h string$=string$+K$
r	 � Z%
| ARRAY$(N%)=string$
� � ARRAY$(N%)
�	 � N%
� �:�"NOW SORTING..."
�R � Turn timer on,note that variable names must be the same as used in the code
� HERE%=�
� � SORT,NUMBER%,ARRAY$(1)
� NOW%=�
� � N%=1 � NUMBER%
� � ARRAY$(N%)
�	 � N%
�B �:�"SORTED ";NUMBER%;" ITEMS IN ";(NOW%-HERE%)/100;" SECONDS"
�7 � Time @ 10 lttrs: 1700=21s ; 400=2.2s ; 100=0.24s
�
00000000  0d 00 0a 37 20 f4 20 4d  61 63 68 69 6e 65 20 63  |...7 . Machine c|
00000010  6f 64 65 20 61 6c 70 68  61 73 6f 72 74 20 66 72  |ode alphasort fr|
00000020  6f 6d 20 62 6f 6f 6b 20  49 53 42 4e 20 30 30 30  |om book ISBN 000|
00000030  33 38 33 31 35 30 37 0d  00 14 a9 20 f4 20 57 6f  |3831507.... . Wo|
00000040  72 6b 73 20 62 79 20 63  6f 6d 70 61 72 69 6e 67  |rks by comparing|
00000050  20 62 69 67 20 63 68 75  6e 6b 73 20 61 74 20 6f  | big chunks at o|
00000060  6e 63 65 20 73 6f 20 74  68 61 74 20 74 68 65 79  |nce so that they|
00000070  20 61 72 65 20 72 6f 75  67 68 6c 79 20 69 6e 20  | are roughly in |
00000080  6f 72 64 65 72 2c 74 68  65 6e 20 73 6f 72 74 69  |order,then sorti|
00000090  6e 67 20 74 68 65 6d 20  61 20 62 69 74 20 66 69  |ng them a bit fi|
000000a0  6e 65 72 20 20 61 6e 64  20 61 20 62 69 74 20 66  |ner  and a bit f|
000000b0  69 6e 65 72 20 2d 20 68  65 6e 63 65 20 74 68 65  |iner - hence the|
000000c0  20 6e 61 6d 65 20 64 69  6d 69 6e 69 73 68 69 6e  | name diminishin|
000000d0  67 20 69 6e 63 72 65 6d  65 6e 74 20 73 6f 72 74  |g increment sort|
000000e0  0d 00 1e 25 4e 55 4d 42  45 52 3d 26 37 30 3a 50  |...%NUMBER=&70:P|
000000f0  4f 49 4e 54 45 52 31 3d  26 37 32 3a 50 4f 57 45  |OINTER1=&72:POWE|
00000100  52 3d 26 37 34 0d 00 28  45 50 4f 49 4e 54 45 52  |R=&74..(EPOINTER|
00000110  32 3d 26 37 35 3a 53 49  5a 45 3d 26 37 37 3a 4c  |2=&75:SIZE=&77:L|
00000120  4f 4f 50 43 4f 55 4e 54  3d 26 37 39 3a 46 4c 41  |OOPCOUNT=&79:FLA|
00000130  47 3d 26 37 42 3a 53 54  4f 52 45 3d 26 37 43 3a  |G=&7B:STORE=&7C:|
00000140  43 59 43 4c 45 53 3d 26  37 45 0d 00 32 33 73 74  |CYCLES=&7E..23st|
00000150  72 69 6e 67 31 3d 26 38  30 3a 73 74 72 69 6e 67  |ring1=&80:string|
00000160  32 3d 26 38 32 3a 6c 65  6e 67 74 68 31 3d 26 38  |2=&82:length1=&8|
00000170  34 3a 6c 65 6e 67 74 68  32 3d 26 38 35 0d 00 3c  |4:length2=&85..<|
00000180  0e de 20 53 4f 52 54 20  35 30 30 0d 00 46 14 e3  |.. SORT 500..F..|
00000190  20 50 41 53 53 3d 30 20  b8 20 32 20 88 20 32 0d  | PASS=0 . 2 . 2.|
000001a0  00 50 0b 50 25 3d 53 4f  52 54 0d 00 5a 0d 5b 4f  |.P.P%=SORT..Z.[O|
000001b0  50 54 20 50 41 53 53 0d  00 64 0d 4c 44 41 20 26  |PT PASS..d.LDA &|
000001c0  30 36 30 31 0d 00 6e 0d  53 54 41 20 53 54 4f 52  |0601..n.STA STOR|
000001d0  45 0d 00 78 0d 4c 44 41  20 26 30 36 30 32 0d 00  |E..x.LDA &0602..|
000001e0  82 0f 53 54 41 20 53 54  4f 52 45 2b 31 0d 00 8c  |..STA STORE+1...|
000001f0  0a 4c 44 59 20 23 30 0d  00 96 0e 53 54 59 20 53  |.LDY #0....STY S|
00000200  49 5a 45 2b 31 0d 00 a0  0d 53 54 59 20 50 4f 57  |IZE+1....STY POW|
00000210  45 52 0d 00 aa 11 4c 44  41 20 28 53 54 4f 52 45  |ER....LDA (STORE|
00000220  29 2c 59 0d 00 b4 0e 53  54 41 20 4e 55 4d 42 45  |),Y....STA NUMBE|
00000230  52 0d 00 be 07 49 4e 59  0d 00 c8 0c 53 54 59 20  |R....INY....STY |
00000240  53 49 5a 45 0d 00 d2 11  4c 44 41 20 28 53 54 4f  |SIZE....LDA (STO|
00000250  52 45 29 2c 59 0d 00 dc  10 53 54 41 20 4e 55 4d  |RE),Y....STA NUM|
00000260  42 45 52 2b 31 0d 00 e6  0d 2e 53 49 5a 45 4c 4f  |BER+1.....SIZELO|
00000270  4f 50 0d 00 f0 0d 49 4e  43 20 50 4f 57 45 52 0d  |OP....INC POWER.|
00000280  00 fa 0c 41 53 4c 20 53  49 5a 45 0d 01 04 0e 52  |...ASL SIZE....R|
00000290  4f 4c 20 53 49 5a 45 2b  31 0d 01 0e 07 53 45 43  |OL SIZE+1....SEC|
000002a0  0d 01 18 0c 4c 44 41 20  53 49 5a 45 0d 01 22 0e  |....LDA SIZE..".|
000002b0  53 42 43 20 4e 55 4d 42  45 52 0d 01 2c 0e 4c 44  |SBC NUMBER..,.LD|
000002c0  41 20 53 49 5a 45 2b 31  0d 01 36 10 53 42 43 20  |A SIZE+1..6.SBC |
000002d0  4e 55 4d 42 45 52 2b 31  0d 01 40 10 42 43 43 20  |NUMBER+1..@.BCC |
000002e0  53 49 5a 45 4c 4f 4f 50  0d 01 4a 0e 2e 4f 55 54  |SIZELOOP..J..OUT|
000002f0  45 52 4c 4f 4f 50 0d 01  54 0e 4c 53 52 20 53 49  |ERLOOP..T.LSR SI|
00000300  5a 45 2b 31 0d 01 5e 0c  52 4f 52 20 53 49 5a 45  |ZE+1..^.ROR SIZE|
00000310  0d 01 68 07 53 45 43 0d  01 72 0e 4c 44 41 20 4e  |..h.SEC..r.LDA N|
00000320  55 4d 42 45 52 0d 01 7c  0c 53 42 43 20 53 49 5a  |UMBER..|.SBC SIZ|
00000330  45 0d 01 86 0e 53 54 41  20 43 59 43 4c 45 53 0d  |E....STA CYCLES.|
00000340  01 90 10 4c 44 41 20 4e  55 4d 42 45 52 2b 31 0d  |...LDA NUMBER+1.|
00000350  01 9a 0e 53 42 43 20 53  49 5a 45 2b 31 0d 01 a4  |...SBC SIZE+1...|
00000360  10 53 54 41 20 43 59 43  4c 45 53 2b 31 0d 01 ae  |.STA CYCLES+1...|
00000370  0c 2e 4d 49 44 4c 4f 4f  50 0d 01 b8 0a 4c 44 41  |..MIDLOOP....LDA|
00000380  20 23 30 0d 01 c2 0c 53  54 41 20 46 4c 41 47 0d  | #0....STA FLAG.|
00000390  01 cc 11 53 54 41 20 4c  4f 4f 50 43 4f 55 4e 54  |...STA LOOPCOUNT|
000003a0  0d 01 d6 13 53 54 41 20  4c 4f 4f 50 43 4f 55 4e  |....STA LOOPCOUN|
000003b0  54 2b 31 0d 01 e0 0d 4c  44 41 20 26 30 36 30 34  |T+1....LDA &0604|
000003c0  0d 01 ea 10 53 54 41 20  50 4f 49 4e 54 45 52 31  |....STA POINTER1|
000003d0  0d 01 f4 0d 4c 44 41 20  26 30 36 30 35 0d 01 fe  |....LDA &0605...|
000003e0  12 53 54 41 20 50 4f 49  4e 54 45 52 31 2b 31 0d  |.STA POINTER1+1.|
000003f0  02 08 0e 4c 44 41 20 53  49 5a 45 2b 31 0d 02 12  |...LDA SIZE+1...|
00000400  0f 53 54 41 20 53 54 4f  52 45 2b 31 0d 02 1c 0c  |.STA STORE+1....|
00000410  4c 44 41 20 53 49 5a 45  0d 02 26 09 41 53 4c 20  |LDA SIZE..&.ASL |
00000420  41 0d 02 30 0f 52 4f 4c  20 53 54 4f 52 45 2b 31  |A..0.ROL STORE+1|
00000430  0d 02 3a 09 41 53 4c 20  41 0d 02 44 0f 52 4f 4c  |..:.ASL A..D.ROL|
00000440  20 53 54 4f 52 45 2b 31  0d 02 4e 07 43 4c 43 0d  | STORE+1..N.CLC.|
00000450  02 58 10 41 44 43 20 50  4f 49 4e 54 45 52 31 0d  |.X.ADC POINTER1.|
00000460  02 62 10 53 54 41 20 50  4f 49 4e 54 45 52 32 0d  |.b.STA POINTER2.|
00000470  02 6c 11 4c 44 41 50 4f  49 4e 54 45 52 31 2b 31  |.l.LDAPOINTER1+1|
00000480  0d 02 76 0f 41 44 43 20  53 54 4f 52 45 2b 31 0d  |..v.ADC STORE+1.|
00000490  02 80 12 53 54 41 20 50  4f 49 4e 54 45 52 32 2b  |...STA POINTER2+|
000004a0  31 0d 02 8a 0e 2e 49 4e  4e 45 52 4c 4f 4f 50 0d  |1.....INNERLOOP.|
000004b0  02 94 0a 4c 44 59 20 23  30 0d 02 9e 14 4c 44 41  |...LDY #0....LDA|
000004c0  20 28 50 4f 49 4e 54 45  52 31 29 2c 59 0d 02 a8  | (POINTER1),Y...|
000004d0  0f 53 54 41 20 73 74 72  69 6e 67 31 0d 02 b2 14  |.STA string1....|
000004e0  4c 44 41 20 28 50 4f 49  4e 54 45 52 32 29 2c 59  |LDA (POINTER2),Y|
000004f0  0d 02 bc 0f 53 54 41 20  73 74 72 69 6e 67 32 0d  |....STA string2.|
00000500  02 c6 07 49 4e 59 0d 02  d0 14 4c 44 41 20 28 50  |...INY....LDA (P|
00000510  4f 49 4e 54 45 52 31 29  2c 59 0d 02 da 11 53 54  |OINTER1),Y....ST|
00000520  41 20 73 74 72 69 6e 67  31 2b 31 0d 02 e4 14 4c  |A string1+1....L|
00000530  44 41 20 28 50 4f 49 4e  54 45 52 32 29 2c 59 0d  |DA (POINTER2),Y.|
00000540  02 ee 11 53 54 41 20 73  74 72 69 6e 67 32 2b 31  |...STA string2+1|
00000550  0d 02 f8 0a 4c 44 59 20  23 33 0d 03 02 14 4c 44  |....LDY #3....LD|
00000560  41 20 28 50 4f 49 4e 54  45 52 31 29 2c 59 0d 03  |A (POINTER1),Y..|
00000570  0c 0f 53 54 41 20 6c 65  6e 67 74 68 31 0d 03 16  |..STA length1...|
00000580  14 4c 44 41 20 28 50 4f  49 4e 54 45 52 32 29 2c  |.LDA (POINTER2),|
00000590  59 0d 03 20 0f 53 54 41  20 6c 65 6e 67 74 68 32  |Y.. .STA length2|
000005a0  0d 03 2a 0a 4c 44 59 20  23 30 0d 03 34 0d 2e 43  |..*.LDY #0..4..C|
000005b0  4f 4d 50 4c 4f 4f 50 0d  03 3e 13 4c 44 41 20 28  |OMPLOOP..>.LDA (|
000005c0  73 74 72 69 6e 67 32 29  2c 59 0d 03 48 14 43 4d  |string2),Y..H.CM|
000005d0  50 20 28 73 74 72 69 6e  67 31 29 2c 59 20 0d 03  |P (string1),Y ..|
000005e0  52 0c 42 43 43 20 53 57  4f 50 0d 03 5c 0e 42 4e  |R.BCC SWOP..\.BN|
000005f0  45 20 4e 4f 53 57 4f 50  0d 03 66 07 49 4e 59 0d  |E NOSWOP..f.INY.|
00000600  03 70 0f 43 50 59 20 6c  65 6e 67 74 68 31 0d 03  |.p.CPY length1..|
00000610  7a 0e 42 45 51 20 4e 4f  53 57 4f 50 0d 03 84 0f  |z.BEQ NOSWOP....|
00000620  43 50 59 20 6c 65 6e 67  74 68 32 0d 03 8e 0c 42  |CPY length2....B|
00000630  45 51 20 53 57 4f 50 0d  03 98 10 42 4e 45 20 43  |EQ SWOP....BNE C|
00000640  4f 4d 50 4c 4f 4f 50 0d  03 a2 0b 2e 53 54 41 47  |OMPLOOP.....STAG|
00000650  45 31 0d 03 ac 0f 42 4e  45 20 4d 49 44 4c 4f 4f  |E1....BNE MIDLOO|
00000660  50 0d 03 b6 0b 2e 53 54  41 47 45 32 0d 03 c0 11  |P.....STAGE2....|
00000670  42 4e 45 20 4f 55 54 45  52 4c 4f 4f 50 0d 03 ca  |BNE OUTERLOOP...|
00000680  09 2e 53 57 4f 50 0d 03  d4 0a 4c 44 59 20 23 33  |..SWOP....LDY #3|
00000690  0d 03 de 0c 53 54 59 20  46 4c 41 47 0d 03 e8 0d  |....STY FLAG....|
000006a0  2e 53 57 4f 50 4c 4f 4f  50 0d 03 f2 14 4c 44 41  |.SWOPLOOP....LDA|
000006b0  20 28 50 4f 49 4e 54 45  52 31 29 2c 59 0d 03 fc  | (POINTER1),Y...|
000006c0  07 54 41 58 0d 04 06 14  4c 44 41 20 28 50 4f 49  |.TAX....LDA (POI|
000006d0  4e 54 45 52 32 29 2c 59  0d 04 10 14 53 54 41 20  |NTER2),Y....STA |
000006e0  28 50 4f 49 4e 54 45 52  31 29 2c 59 0d 04 1a 07  |(POINTER1),Y....|
000006f0  54 58 41 0d 04 24 14 53  54 41 20 28 50 4f 49 4e  |TXA..$.STA (POIN|
00000700  54 45 52 32 29 2c 59 0d  04 2e 07 44 45 59 0d 04  |TER2),Y....DEY..|
00000710  38 10 42 50 4c 20 53 57  4f 50 4c 4f 4f 50 0d 04  |8.BPL SWOPLOOP..|
00000720  42 0b 2e 4e 4f 53 57 4f  50 0d 04 4c 11 49 4e 43  |B..NOSWOP..L.INC|
00000730  20 4c 4f 4f 50 43 4f 55  4e 54 0d 04 56 0c 42 4e  | LOOPCOUNT..V.BN|
00000740  45 20 53 4b 49 50 0d 04  60 13 49 4e 43 20 4c 4f  |E SKIP..`.INC LO|
00000750  4f 50 43 4f 55 4e 54 2b  31 0d 04 6a 09 2e 53 4b  |OPCOUNT+1..j..SK|
00000760  49 50 0d 04 74 10 4c 44  41 20 50 4f 49 4e 54 45  |IP..t.LDA POINTE|
00000770  52 31 0d 04 7e 07 43 4c  43 0d 04 88 0a 41 44 43  |R1..~.CLC....ADC|
00000780  20 23 34 0d 04 92 10 53  54 41 20 50 4f 49 4e 54  | #4....STA POINT|
00000790  45 52 31 0d 04 9c 0d 42  43 43 20 53 4b 49 50 32  |ER1....BCC SKIP2|
000007a0  0d 04 a6 12 49 4e 43 20  50 4f 49 4e 54 45 52 31  |....INC POINTER1|
000007b0  2b 31 0d 04 b0 0a 2e 53  4b 49 50 32 0d 04 ba 10  |+1.....SKIP2....|
000007c0  4c 44 41 20 50 4f 49 4e  54 45 52 32 0d 04 c4 07  |LDA POINTER2....|
000007d0  43 4c 43 0d 04 ce 0a 41  44 43 20 23 34 0d 04 d8  |CLC....ADC #4...|
000007e0  10 53 54 41 20 50 4f 49  4e 54 45 52 32 0d 04 e2  |.STA POINTER2...|
000007f0  0d 42 43 43 20 53 4b 49  50 33 0d 04 ec 12 49 4e  |.BCC SKIP3....IN|
00000800  43 20 50 4f 49 4e 54 45  52 32 2b 31 0d 04 f6 0a  |C POINTER2+1....|
00000810  2e 53 4b 49 50 33 0d 05  00 0e 4c 44 41 20 43 59  |.SKIP3....LDA CY|
00000820  43 4c 45 53 0d 05 0a 11  43 4d 50 20 4c 4f 4f 50  |CLES....CMP LOOP|
00000830  43 4f 55 4e 54 0d 05 14  11 42 4e 45 20 49 4e 4e  |COUNT....BNE INN|
00000840  45 52 4c 4f 4f 50 0d 05  1e 10 4c 44 41 20 43 59  |ERLOOP....LDA CY|
00000850  43 4c 45 53 2b 31 0d 05  28 13 43 4d 50 20 4c 4f  |CLES+1..(.CMP LO|
00000860  4f 50 43 4f 55 4e 54 2b  31 0d 05 32 11 42 4e 45  |OPCOUNT+1..2.BNE|
00000870  20 49 4e 4e 45 52 4c 4f  4f 50 0d 05 3c 0c 4c 44  | INNERLOOP..<.LD|
00000880  41 20 46 4c 41 47 0d 05  46 11 42 45 51 20 46 4c  |A FLAG..F.BEQ FL|
00000890  41 47 43 4c 45 41 52 0d  05 50 07 53 45 43 0d 05  |AGCLEAR..P.SEC..|
000008a0  5a 0e 4c 44 41 20 43 59  43 4c 45 53 0d 05 64 0a  |Z.LDA CYCLES..d.|
000008b0  53 42 43 20 23 31 0d 05  6e 0e 53 54 41 20 43 59  |SBC #1..n.STA CY|
000008c0  43 4c 45 53 0d 05 78 0d  42 43 53 20 53 4b 49 50  |CLES..x.BCS SKIP|
000008d0  34 0d 05 82 10 44 45 43  20 43 59 43 4c 45 53 2b  |4....DEC CYCLES+|
000008e0  31 0d 05 8c 0e 4c 44 41  20 43 59 43 4c 45 53 0d  |1....LDA CYCLES.|
000008f0  05 96 0a 2e 53 4b 49 50  34 0d 05 a0 0e 42 4e 45  |....SKIP4....BNE|
00000900  20 53 54 41 47 45 31 0d  05 aa 10 4c 44 41 20 43  | STAGE1....LDA C|
00000910  59 43 4c 45 53 2b 31 0d  05 b4 0e 42 4e 45 20 53  |YCLES+1....BNE S|
00000920  54 41 47 45 31 0d 05 be  0e 2e 46 4c 41 47 43 4c  |TAGE1.....FLAGCL|
00000930  45 41 52 0d 05 c8 0d 44  45 43 20 50 4f 57 45 52  |EAR....DEC POWER|
00000940  0d 05 d2 0e 42 4e 45 20  53 54 41 47 45 32 0d 05  |....BNE STAGE2..|
00000950  dc 0a 20 52 54 53 3a 5d  0d 05 e6 0a ed 20 50 41  |.. RTS:]..... PA|
00000960  53 53 0d 05 f0 49 20 f4  20 42 61 73 69 63 20 66  |SS...I . Basic f|
00000970  72 6f 6d 20 68 65 72 65  20 6f 6e 77 61 72 64 73  |rom here onwards|
00000980  20 69 73 20 79 6f 75 72  20 70 72 6f 67 72 61 6d  | is your program|
00000990  20 74 68 61 74 20 75 73  65 73 20 74 68 65 20 61  | that uses the a|
000009a0  62 6f 76 65 20 73 6f 72  74 65 72 0d 05 fa 06 20  |bove sorter.... |
000009b0  db 0d 06 04 21 e8 22 4e  55 4d 42 45 52 20 4f 46  |....!."NUMBER OF|
000009c0  20 53 54 52 49 4e 47 53  20 22 3b 4e 55 4d 42 45  | STRINGS ";NUMBE|
000009d0  52 25 0d 06 0e 4b 20 20  e7 20 4e 55 4d 42 45 52  |R%...K  . NUMBER|
000009e0  25 3e 31 30 30 30 20 8c  20 f1 22 54 4f 4f 20 4d  |%>1000 . ."TOO M|
000009f0  41 4e 59 22 3a e5 20 8d  54 44 46 3a f4 20 41 6c  |ANY":. .TDF:. Al|
00000a00  74 65 72 73 20 64 65 70  65 6e 64 69 6e 67 20 6f  |ters depending o|
00000a10  6e 20 73 63 72 65 65 6e  20 6d 6f 64 65 0d 06 18  |n screen mode...|
00000a20  06 20 f1 0d 06 22 16 20  de 20 41 52 52 41 59 24  |. ...". . ARRAY$|
00000a30  28 4e 55 4d 42 45 52 25  29 0d 06 2c 2b 20 f4 20  |(NUMBER%)..,+ . |
00000a40  52 61 6e 64 6f 6d 6c 79  20 67 65 6e 65 72 61 74  |Randomly generat|
00000a50  65 73 20 31 30 20 6c 65  74 74 65 72 20 73 74 72  |es 10 letter str|
00000a60  69 6e 67 73 0d 06 36 1a  20 f1 3a f1 22 53 54 52  |ings..6. .:."STR|
00000a70  49 4e 47 53 20 41 52 45  2e 2e 2e 22 3a f1 0d 06  |INGS ARE...":...|
00000a80  40 15 20 e3 20 4e 25 3d  31 20 b8 20 4e 55 4d 42  |@. . N%=1 . NUMB|
00000a90  45 52 25 0d 06 4a 0f 20  73 74 72 69 6e 67 24 3d  |ER%..J. string$=|
00000aa0  22 22 0d 06 54 13 20 e3  20 5a 25 3d 31 20 b8 20  |""..T. . Z%=1 . |
00000ab0  b3 28 31 30 29 0d 06 5e  13 20 4b 24 3d bd 28 b3  |.(10)..^. K$=.(.|
00000ac0  28 32 36 29 2b 36 34 29  0d 06 68 17 20 73 74 72  |(26)+64)..h. str|
00000ad0  69 6e 67 24 3d 73 74 72  69 6e 67 24 2b 4b 24 0d  |ing$=string$+K$.|
00000ae0  06 72 09 20 ed 20 5a 25  0d 06 7c 17 20 41 52 52  |.r. . Z%..|. ARR|
00000af0  41 59 24 28 4e 25 29 3d  73 74 72 69 6e 67 24 0d  |AY$(N%)=string$.|
00000b00  06 86 11 20 f1 20 41 52  52 41 59 24 28 4e 25 29  |... . ARRAY$(N%)|
00000b10  0d 06 90 09 20 ed 20 4e  25 0d 06 9a 18 20 f1 3a  |.... . N%.... .:|
00000b20  f1 22 4e 4f 57 20 53 4f  52 54 49 4e 47 2e 2e 2e  |."NOW SORTING...|
00000b30  22 0d 06 a4 52 20 f4 20  54 75 72 6e 20 74 69 6d  |"...R . Turn tim|
00000b40  65 72 20 6f 6e 2c 6e 6f  74 65 20 74 68 61 74 20  |er on,note that |
00000b50  76 61 72 69 61 62 6c 65  20 6e 61 6d 65 73 20 6d  |variable names m|
00000b60  75 73 74 20 62 65 20 74  68 65 20 73 61 6d 65 20  |ust be the same |
00000b70  61 73 20 75 73 65 64 20  69 6e 20 74 68 65 20 63  |as used in the c|
00000b80  6f 64 65 0d 06 ae 0c 20  48 45 52 45 25 3d 91 0d  |ode.... HERE%=..|
00000b90  06 b8 1d 20 d6 20 53 4f  52 54 2c 4e 55 4d 42 45  |... . SORT,NUMBE|
00000ba0  52 25 2c 41 52 52 41 59  24 28 31 29 0d 06 c2 0b  |R%,ARRAY$(1)....|
00000bb0  20 4e 4f 57 25 3d 91 0d  06 cc 15 20 e3 20 4e 25  | NOW%=..... . N%|
00000bc0  3d 31 20 b8 20 4e 55 4d  42 45 52 25 0d 06 d6 11  |=1 . NUMBER%....|
00000bd0  20 f1 20 41 52 52 41 59  24 28 4e 25 29 0d 06 e0  | . ARRAY$(N%)...|
00000be0  09 20 ed 20 4e 25 0d 06  ea 42 20 f1 3a f1 22 53  |. . N%...B .:."S|
00000bf0  4f 52 54 45 44 20 22 3b  4e 55 4d 42 45 52 25 3b  |ORTED ";NUMBER%;|
00000c00  22 20 49 54 45 4d 53 20  49 4e 20 22 3b 28 4e 4f  |" ITEMS IN ";(NO|
00000c10  57 25 2d 48 45 52 45 25  29 2f 31 30 30 3b 22 20  |W%-HERE%)/100;" |
00000c20  53 45 43 4f 4e 44 53 22  0d 06 f4 37 20 f4 20 54  |SECONDS"...7 . T|
00000c30  69 6d 65 20 40 20 31 30  20 6c 74 74 72 73 3a 20  |ime @ 10 lttrs: |
00000c40  31 37 30 30 3d 32 31 73  20 3b 20 34 30 30 3d 32  |1700=21s ; 400=2|
00000c50  2e 32 73 20 3b 20 31 30  30 3d 30 2e 32 34 73 0d  |.2s ; 100=0.24s.|
00000c60  ff                                                |.|
00000c61
P/ABC-F.m0
P/ABC-F.m1
P/ABC-F.m2
P/ABC-F.m4
P/ABC-F.m5