home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG182.ARC
/
DISASSEM.BAS
< prev
next >
Wrap
BASIC Source File
|
1979-12-31
|
16KB
|
505 lines
10000 ' Z-80 Dissassembler
10010 ' Based on disassembler on page 42
10020 ' of Dr. Dobbs Journal number 26
10030 '
10040 DEFINT A-Z
10050 '
10060 ' Convert letter to upper case
10070 DEF FNUPPER$(CC$)=CHR$(ASC(CC$)+(CC$>="a" AND CC$<="z")*32)
10080 '
10090 DIM B(6),BB(12),BIT(7),REG$(7),RP$(3),AI$(7)
10100 DIM JR$(7),CC$(7),C1$(7),C3$(7),C5$(7)
10110 DIM O7$(7),O2$(7),CB$(3),RT$(7),ED$(7)
10120 DIM CP$(7),TS(80)
10130 '
10140 RECLN=128
10150 ON ERROR GOTO 14950
10160 '
10170 GOSUB 14350: 'initialize arrays and constants
10180 GOSUB 14630
10190 PRINT CS$;: GOSUB 14010
10200 PRINT "Z-80 Disassembler"
10210 RESET
10220 PRINT
10230 LINE INPUT "File name? ",S$: IF S$="" THEN END
10240 FILE$=""
10250 FOR I=1 TO LEN(S$): FILE$=FILE$+FNUPPER$(MID$(S$,I,1)): NEXT I
10260 N=INSTR(FILE$,".")
10270 IF N THEN FLNAME$=LEFT$(FILE$,N-1) ELSE FLNAME$=FILE$
10280 IF N=0 THEN FILE$=FILE$+".COM"
10290 FILEERR=FALSE
10300 OPEN "I",#1,FILE$
10310 IF FILEERR THEN 10230
10320 CLOSE#1
10330 OPEN "R",#1,FILE$,RECLN
10340 FIELD#1,128 AS INREC$
10350 LINE INPUT "Address of start of file? ",S$
10360 IF S$="" THEN ASTRT!=&H100
10370 IF S$<>"" THEN GOSUB 14450: ASTRT!=T!: IF BAD THEN 10350
10380 LINE INPUT "Start address? ",S$
10390 IF S$="" THEN T!=ASTRT!
10400 IF S$<>"" THEN GOSUB 14450: IF BAD THEN 10380
10410 IF T!<ASTRT! THEN 10380
10420 PC!=T!
10430 LINE INPUT "End address? ",S$
10440 IF S$="" THEN PE!=1E+10: GOTO 10470
10450 GOSUB 14450: IF BAD THEN 10380
10460 PE!=T!
10470 INPUT "Output file( *=LST, **=CON)? ",S$
10480 IF S$="*" THEN OUTOPT=1: GOTO 10580
10490 IF S$="**" THEN OUTOPT=2: GOTO 10580
10500 IF S$="" THEN S$=FLNAME$
10510 OUTOPT=3
10520 FILE$=""
10530 FOR I=1 TO LEN(S$)
10540 FILE$=FILE$+FNUPPER$(MID$(S$,I,1))
10550 NEXT I
10560 IF INSTR(FILE$,".")=0 THEN FILE$=FILE$+".ASM"
10570 OPEN "O",#2,FILE$
10580 DL!=1E+10: DH!=1E+10
10590 LINE INPUT "DEFB Control file (Y OR N)? ",C$
10600 IF C$="" THEN 10710
10610 IF FNUPPER$(C$)<>"Y" THEN 10710
10620 FILE$=FLNAME$+".CTL"
10630 FILEERR=FALSE
10640 OPEN "I",#3,FILE$
10650 IF NOT FILEERR THEN 10690
10660 INPUT "Continue without control file? ",C$
10670 IF C$="" THEN 10210
10680 IF FNUPPER$(C$)<>"Y" THEN 10210 ELSE 10740
10690 DL!=-1: DH!=-1
10700 '
10710 PRINT: PRINT
10720 '
10730 ' initialize input file
10740 N=INT((PC!-ASTRT!)/RECLN): RECPT=PC!-ASTRT!-RECLN*N
10750 GET#1,N+1
10760 IF EOF(1) THEN 11380
10770 ENDFILE=FALSE: NBB=0
10780 '
10790 ' put org statement
10800 DLINE$=SPACE$(7)+"ORG"+SPACE$(5)
10810 X!=PC!
10820 GOSUB 12600
10830 GOSUB 11340
10840 '
10850 ' Main loop
10860 NB=0: BADOP=FALSE
10870 WHILE PC!>DH!
10880 IF EOF(3) THEN DL!=1E+10: DH!=1E+10: GOTO 11010
10890 LINE INPUT#3,DLINE$
10900 C$=DLINE$: GOSUB 14820
10910 I=INSTR(C$," "): IF I=0 THEN GOSUB 14890: GOTO 11010
10920 S$=LEFT$(C$,I-1): C$=RIGHT$(C$,LEN(C$)-I): GOSUB 14450
10930 IF BAD THEN GOSUB 14890: GOTO 11010
10940 DL!=T!
10950 GOSUB 14820
10960 I=INSTR(C$," "): IF I THEN C$=LEFT$(C$,I-1)
10970 S$=C$: GOSUB 14450
10980 IF BAD THEN GOSUB 14890: GOTO 11010
10990 IF T!<DL! THEN GOSUB 14890: GOTO 11010
11000 DH!=T!
11010 WEND
11020 HOLDPC!=PC!
11030 IF PC!>=DL! THEN 11120
11040 DLINE$=SPACE$(7)
11050 GOSUB 12310: OP=X!
11060 GOSUB 11490
11070 IF ENDFILE AND NOT NB THEN 11300
11080 IF NOT BADOP THEN 11140
11090 FOR NB=NB TO 1 STEP -1
11100 NBB=NBB+1: BB(NBB)=B(NB): PC!=PC!-1
11110 NEXT NB
11120 BADOP=FALSE: GOSUB 11410
11130 IF BADOP THEN 11300
11140 TB=32: GOSUB 14590: DLINE$=DLINE$+";"
11150 X!=HOLDPC!: GOSUB 12630: DLINE$=DLINE$+" "
11160 FOR I=1 TO NB
11170 X!=B(I)
11180 DLINE$=DLINE$+" "
11190 GOSUB 12480
11200 NEXT I
11210 TB=52: GOSUB 14590
11220 FOR I=1 TO NB
11230 C$=".": IF B(I)>=32 AND B(I)<127 THEN C$=CHR$(B(I))
11240 IF B(I)>=160 AND B(I)<255 THEN C$=CHR$(B(I))
11250 DLINE$=DLINE$+C$
11260 NEXT I
11270 GOSUB 11340
11280 IF PC!<PE! THEN 10860
11290 '
11300 RESET
11310 GOTO 10210
11320 '
11330 ' output line
11340 ON OUTOPT GOTO 11350,11360,11370
11350 LPRINT DLINE$: GOTO 11380
11360 PRINT DLINE$: GOTO 11380
11370 S$=DLINE$: GOSUB 14690: PRINT#2,DLINE$
11380 RETURN
11390 '
11400 ' Generate a defb
11410 DLINE$=SPACE$(7)+"DEFB"+SPACE$(4)
11420 GOSUB 12310: GOSUB 12450
11430 RETURN
11440 '
11450 ' Separate parts of op code
11460 L=OP\BIT(6): M=OP\BIT(3) AND 7: K=OP AND 7: RETURN
11470 '
11480 ' Disassemble one op
11490 GOSUB 11460: ON L GOTO 11890,11950,11970
11500 ON K GOTO 11580,11660,11740,11800,11800,11840,11880
11510 IF M=1 THEN S$="EX AF,AF'"
11520 IF M=0 THEN S$="NOP"
11530 IF M=1 OR M=0 THEN 12690
11540 S$=JR$(M): GOSUB 12690: GOSUB 12770
11550 GOSUB 12310: IF X!>127 THEN X!=X!-256
11560 X!=PC!+X!: GOSUB 12600: RETURN
11570 '
11580 K=M\BIT(1)
11590 IF OP AND BIT(3) THEN 11640
11600 S$="LD ": GOSUB 12690:
11610 S$=RP$(K): GOSUB 12690
11620 S$=",": GOSUB 12690
11630 GOSUB 12540: RETURN
11640 S$="ADD HL,": GOSUB 12690
11650 S$=RP$(K): GOTO 12690
11660 S$=O2$(M): GOSUB 12690
11670 IF M<4 THEN RETURN
11680 GOSUB 12770: GOSUB 12510: GOSUB 12570
11690 IF M=4 THEN S$=",HL": GOSUB 12690
11700 IF M=6 THEN S$=",A": GOSUB 12690
11710 RETURN
11720 GOSUB 12540: RETURN
11730 '
11740 K=M\BIT(1)
11750 M=M AND BIT(0)
11760 IF M=0 THEN S$="INC "
11770 IF M=1 THEN S$="DEC "
11780 GOSUB 12690
11790 S$=RP$(K): GOTO 12690
11800 IF K=4 THEN S$="INC "
11810 IF K=5 THEN S$="DEC "
11820 GOSUB 12690
11830 S$=REG$(M): GOTO 12690
11840 S$="LD ": GOSUB 12690
11850 S$=REG$(M): GOSUB 12690
11860 S$=",": GOSUB 12690
11870 GOSUB 12490: RETURN
11880 S$=O7$(M): GOTO 12690
11890 IF M=6 AND K=6 THEN 11940
11900 S$="LD ": GOSUB 12690
11910 S$=REG$(M): GOSUB 12690
11920 S$=",": GOSUB 12690
11930 S$=REG$(K): GOTO 12690
11940 S$="HLT": GOTO 12690
11950 S$=AI$(M): GOSUB 12690
11960 GOSUB 12770: GOTO 11930
11970 ON K GOTO 12000,12010,12080,12020,12180,12260,12280
11980 S$="RET ": GOSUB 12690
11990 S$=CC$(M): GOTO 12690
12000 S$=C1$(M): GOTO 12690
12010 S$="JP ": GOTO 12030
12020 S$="CALL ":
12030 GOSUB 12690
12040 S$=CC$(M): GOSUB 12690
12050 S$=",": GOSUB 12690
12060 GOSUB 12540
12070 RETURN
12080 IF M=1 THEN 12790
12090 S$=C3$(M): IF S$="???" THEN BADOP=TRUE: RETURN
12100 GOSUB 12690
12110 IF M=0 THEN 12140
12120 IF M=2 OR M=3 THEN 12150
12130 RETURN
12140 GOSUB 12770:GOSUB 12540: RETURN
12150 GOSUB 12770: GOSUB 12310: GOSUB 12420
12160 IF M=2 THEN S$=",A": GOSUB 12690
12170 RETURN
12180 IF M=5 THEN 12900
12190 IF M=3 THEN I$="IX"
12200 IF M=7 THEN I$="IY"
12210 IF M=3 OR M=7 THEN 13320
12220 S$=C5$(M): IF S$="???" THEN BADOP=TRUE: RETURN
12230 GOSUB 12690
12240 IF M<>1 THEN RETURN
12250 GOSUB 12770: GOSUB 12540: RETURN
12260 S$=AI$(M): GOSUB 12690: GOSUB 12770
12270 GOSUB 12490: RETURN
12280 S$="RST ": GOSUB 12690
12290 X!=8*M: GOSUB 12450
12300 RETURN
12310 IF NBB THEN X!=BB(NBB): NBB=NBB-1: PC!=PC!+1: RETURN
12320 IF ENDFILE THEN BADOP=TRUE: X!=0: RETURN
12330 RECPT=RECPT+1: IF RECPT<=RECLN THEN 12370
12340 GET#1
12350 IF EOF(1) THEN X!=0: ENDFILE=TRUE: RETURN
12360 RECPT=1
12370 X!=ASC(MID$(INREC$,RECPT,1)): PC!=PC!+1
12380 NB=NB+1: B(NB)=X!
12390 RETURN
12400 '
12410 ' Insert (1 byte hex)
12420 DLINE$=DLINE$+"(": GOSUB 12450: DLINE$=DLINE$+")": RETURN
12430 '
12440 ' Insert a 1 byte hex constant in assembly
12450 DLINE$=DLINE$+"0": GOSUB 12480: DLINE$=DLINE$+"H": RETURN
12460 '
12470 ' Insert a one byte hex number
12480 DLINE$=DLINE$+RIGHT$("0"+HEX$(X!),2): RETURN
12490 GOSUB 12310: GOSUB 12450: RETURN
12500 '
12510 GOSUB 12310: XL=X!
12520 GOSUB 12310: XH=X!
12530 X!=XL+256*XH: RETURN
12540 GOSUB 12510: GOSUB 12600: RETURN
12550 '
12560 ' Insert (hex)
12570 DLINE$=DLINE$+"(": GOSUB 12600: DLINE$=DLINE$+")": RETURN
12580 '
12590 ' Insert a 2 byte hex constant in assembly
12600 DLINE$=DLINE$+"0": GOSUB 12630: DLINE$=DLINE$+"H": RETURN
12610 '
12620 ' Insert a 2 byte hex number
12630 DLINE$=DLINE$+RIGHT$("000"+HEX$(X!),4): RETURN
12640 '
12650 ' Insert (alpha)
12660 DLINE$=DLINE$+"(": GOSUB 12690: DLINE$=DLINE$+")": RETURN
12670 '
12680 ' Add code to line
12690 FOR I=1 TO LEN(S$)
12700 C$=MID$(S$,I,1)
12710 IF C$=" " THEN GOSUB 12770: GOTO 12730
12720 DLINE$=DLINE$+C$
12730 NEXT I
12740 RETURN
12750 '
12760 ' Start operand field
12770 TB=16: GOSUB 14590: RETURN
12780 '
12790 GOSUB 12310: OP=X!
12800 L=OP\BIT(6)
12810 M=(OP\BIT(3)) AND 7
12820 K=OP AND 7
12830 IF L=0 THEN 12870
12840 S$=CB$(L): GOSUB 12690: GOSUB 12770
12850 S$=CHR$(48+M): GOSUB 12690: S$=",": GOSUB 12690
12860 S$=REG$(K): GOTO 12690
12870 S$=RT$(M): IF S$="???" THEN BADOP=TRUE: RETURN
12880 GOSUB 12690
12890 S$=REG$(K): GOTO 12690
12900 GOSUB 12310: OP=X!
12910 L=OP\BIT(6): M=(OP\BIT(3)) AND 7: K=OP AND 7
12920 ON L GOTO 12940,13300,12930
12930 BADOP=TRUE: RETURN
12940 ON K GOTO 12970,12990,13040,13150,13180,13230,13280
12950 S$="IN": GOSUB 12690
12960 S$=REG$(M): GOSUB 12690: S$=",(C)": GOTO 12690
12970 S$="OUT (C),": GOSUB 12690
12980 S$=REG$(M): GOTO 12690
12990 K=M\BIT(1): M=M AND BIT(0)
13000 IF M=1 THEN S$="ADC HL,"
13010 IF M=0 THEN S$="SBC HL,"
13020 GOSUB 12690
13030 S$=RP$(K): GOTO 12690
13040 K=M\BIT(1): M=M AND BIT(0)
13050 S$="LD ": GOSUB 12690
13060 IF M=1 THEN 13110
13070 GOSUB 12510: GOSUB 12570
13080 S$=",": GOSUB 12690
13090 S$=RP$(K): GOSUB 12690
13100 RETURN
13110 S$=RP$(K): GOSUB 12690
13120 S$=",": GOSUB 12690
13130 GOSUB 12510: GOSUB 12570
13140 RETURN
13150 IF M=0 THEN 13170
13160 BADOP=TRUE: RETURN
13170 S$="NEG": GOTO 12690
13180 IF M<=1 THEN 13200
13190 GOTO 13160
13200 IF M=1 THEN S$="RETI"
13210 IF M=0 THEN S$="RETN"
13220 GOTO 12690
13230 IF M=1 OR M>3 THEN BADOP=TRUE: RETURN
13240 IF M=0 THEN S$="IM0"
13250 IF M=2 THEN S$="IM1"
13260 IF M=3 THEN S$="IM2"
13270 GOTO 12690
13280 S$=ED$(M): IF S$="???" THEN BADOP=TRUE: RETURN
13290 GOTO 12690
13300 S$=CP$(K)+CP$(M): IF S$="OUTIR" THEN S$="OTIR
13310 GOTO 12690
13320 GOSUB 12310: OP=X!
13330 IF OP=203 THEN 13870
13340 L=OP\BIT(6): M=(OP\BIT(3)) AND 7
13350 K=OP AND 7
13360 ON L GOTO 13650,13710,13740
13370 ON K GOTO 13390,13480,13530,13560,13560,13620
13380 S$="==": GOTO 12690
13390 IF M=4 THEN 13460
13400 K=M\BIT(1): M=M AND BIT(0)
13410 S$="ADD ": GOSUB 12690: S$=I$: GOSUB 12690
13420 S$=",": GOSUB 12690
13430 IF K=2 THEN 13450
13440 S$=RP$(K): GOTO 12690
13450 S$=I$: GOTO 12690
13460 S$="LD ": GOSUB 12690: S$=I$: GOSUB 12690
13470 S$=",": GOSUB 12690: GOSUB 12510: GOSUB 12600: RETURN
13480 IF M=4 THEN 13510
13490 S$="LD ": GOSUB 12690: S$=I$: GOSUB 12690
13500 S$=",": GOSUB 12690: GOSUB 12510: GOSUB 12570: RETURN
13510 S$="LD ": GOSUB 12690: GOSUB 12510: GOSUB 12570: S$=",": GOSUB 12690
13520 S$=I$: GOTO 12690
13530 IF M=4 THEN S$="INC "
13540 IF M=5 THEN S$="DEC "
13550 GOSUB 12690: S$=I$: GOTO 12690
13560 IF K=4 THEN S$="INC "
13570 IF K=5 THEN S$="DEC "
13580 GOSUB 12690
13590 S$="(": GOSUB 12690: S$=I$: GOSUB 12690
13600 S$="+": GOSUB 12690: GOSUB 12310: GOSUB 12450
13610 S$=")": GOTO 12690
13620 IF M<>6 THEN 13380
13630 S$="LD ": GOSUB 13580: S$=",": GOSUB 12690
13640 GOSUB 12310: GOSUB 12450: RETURN
13650 S$="LD "
13660 IF K=6 THEN 13690
13670 GOSUB 13580: S$=",": GOSUB 12690
13680 S$=REG$(K): GOTO 12690
13690 GOSUB 12690: S$=REG$(M): GOSUB 12690: S$=","
13700 GOSUB 13580:RETURN
13710 IF K<>6 THEN 13730
13720 S$=AI$(M): GOSUB 13580: RETURN
13730 BADOP=TRUE: RETURN
13740 IF M<>4 THEN 13820
13750 ON K GOTO 13770,13760,13780,13760,13800,13760,13760
13760 BADOP=TRUE: RETURN
13770 S$="POP ": GOTO 13810
13780 S$="EX (SP),": GOTO 13810
13790 S$="LD SP,": GOTO 13810
13800 S$="PUSH "
13810 GOSUB 12690: S$=I$: GOTO 12690
13820 IF M<>5 THEN 13860
13830 IF K<>1 THEN 13760
13840 S$="JP ": S$="(" GOSUB 12690:
13850 S$=D$: GOSUB 12690: S$=")": GOSUB 12690: RETURN
13860 IF M=7 AND K=1 THEN 13790
13870 GOSUB 12310: D=X!
13880 GOSUB 12310: OP=X!
13890 GOSUB 11460
13900 IF L>0 THEN 13960
13910 IF K<>6 THEN 13760
13920 S$=RT$(M): IF S$="???" THEN BADOP=TRUE: RETURN
13930 GOSUB 12760: GOSUB 12690: GOSUB 12770
13940 S$="("+I$+"+": GOSUB 12690
13950 X!=D: GOSUB 12450: S$=")": GOSUB 12690: RETURN
13960 S$=CB$(L): GOSUB 12690
13970 S$=CHR$(48+M): GOSUB 12690
13980 S$=",": GOSUB 12690: GOTO 13940
13990 '
14000 ' initialize tables
14010 FOR I=0 TO 7: READ BIT(I): NEXT I
14020 DATA 1,2,4,8,16,32,64,128
14030 FOR I=0 TO 7: READ REG$(I): NEXT I
14040 DATA B,C,D,E,H,L,(HL),A
14050 FOR I=0 TO 3: READ RP$(I): NEXT I
14060 DATA BC,DE,HL,SP
14070 FOR I=0 TO 7: READ AI$(I): NEXT I
14080 DATA ADD,"ADC A,",SUB,"SBC A,",AND,XOR,OR,CP
14090 FOR I=2 TO 7: READ JR$(I): NEXT I
14100 DATA DJNZ,JR,"JR NZ,","JR Z,","JR NC,","JR C,"
14110 FOR I=0 TO 7: READ CC$(I): NEXT I
14120 DATA NZ,Z,NC,C,PO,PE,P,M
14130 FOR I=0 TO 7: READ C1$(I): NEXT I
14140 DATA POP BC,RET,POP DE,EXX,POP HL,JP (HL),POP AF,"LD SP,HL"
14150 FOR I=0 TO 7: READ C3$(I): NEXT I
14160 DATA JP,???,OUT,"IN A,","EX (SP),HL","EX DE,HL",DI,EI
14170 FOR I=0 TO 7: READ C5$(I): NEXT I
14180 DATA PUSH BC,CALL,PUSH DE,???,PUSH HL,???,PUSH AF,???
14190 FOR I=0 TO 7: READ O7$(I): NEXT I
14200 DATA RLCA,RRCA,RLA,RRA,DAA,CPL,SCF,CCF
14210 FOR I=0 TO 7: READ O2$(I): NEXT I
14220 DATA "LD (BC),A","LD A,(BC)"
14230 DATA "LD (DE),A","LD A,(DE)"
14240 DATA LD,"LD HL,",LD,"LD A,"
14250 FOR I=1 TO 3: READ CB$(I): NEXT I
14260 DATA BIT,RES,SET
14270 FOR I=0 TO 7: READ RT$(I): NEXT I
14280 DATA RLC,RRC,RAL,RAR,SLA,SRA,???,SRL
14290 FOR I=0 TO 7: READ ED$(I): NEXT I
14300 DATA "LD I,A","LD R,A"
14310 DATA "LD A,I","LD A,R",RRD,RLD,???,???
14320 FOR I=0 TO 7: READ CP$(I): NEXT I
14330 DATA LD,CP,IN,OUT,I,D,IR,DR
14340 TRUE=-1: FALSE=0: RETURN
14350 TS=2: TD=3: KB=2: SB=2
14360 BS$=CHR$(8)
14370 HT$=CHR$(9)
14380 ES$=CHR$(27)
14390 CS$=CHR$(26)+ES$+"S"+CHR$(0)+CHR$(32)
14400 EL$=ES$+"R"
14410 CR$=CHR$(13)
14420 RETURN
14430 '
14440 ' Convert input hex
14450 IF LEN(S$)=0 OR LEN(S$)>4 THEN BAD = -1: RETURN
14460 T!=0
14470 FOR II=1 TO LEN(S$)
14480 CC$=MID$(S$,II,1)
14490 IF CC$>="0" AND CC$<="9" THEN D=ASC(CC$)-ASC("0"): GOTO 14530
14500 IF CC$>="A" AND CC$<="F" THEN D=10+ASC(CC$)-ASC("A"): GOTO 14530
14510 IF CC$>="a" AND CC$<="f" THEN D=10+ASC(CC$)-ASC("a"): GOTO 14530
14520 BAD=-1: RETURN
14530 T!=D+16*T!
14540 NEXT II
14550 BAD=0
14560 RETURN
14570 '
14580 ' Tab line to field
14590 IF LEN(DLINE$)<TB-1 THEN DLINE$=DLINE$+SPACE$(TB-1-LEN(DLINE$))
14600 RETURN
14610 '
14620 ' Setab
14630 FOR II=1 TO 80
14640 TS(II)=(II MOD 8=0)
14650 NEXT II
14660 RETURN
14670 '
14680 ' Entab
14690 DLINE$="": BCNT=0: POSN=0
14700 FOR II=1 TO LEN(S$)
14710 POSN=POSN+1
14720 IF POSN>80 THEN 14740
14730 IF BCNT THEN IF TS(POSN) THEN DLINE$=DLINE$+HT$: BCNT=0
14740 C$=MID$(S$,II,1)
14750 IF C$=" " THEN BCNT=BCNT+1: GOTO 14780
14760 DLINE$=DLINE$+SPACE$(BCNT)+C$
14770 BCNT=0
14780 NEXT II
14790 RETURN
14800 '
14810 ' Remove leading blanks
14820 FOR II=1 TO LEN(C$)
14830 IF MID$(C$,II,1)<>" " THEN C$=RIGHT$(C$,LEN(C$)-II+1): RETURN
14840 NEXT II
14850 C$=""
14860 RETURN
14870 '
14880 ' Error on ctl file
14890 PRINT "Invalid ctl record:"
14900 PRINT DLINE$
14910 PRINT
14920 RETURN
14930 '
14940 ' error handling
14950 IF ERR<>53 THEN 14990
14960 FILEERR=TRUE
14970 PRINT "File not found"
14980 RESUME NEXT
14990 IF ERR<>64 THEN 15030
15000 FILEERR=TRUE
15010 PRINT "Invalid file name"
15020 RESUME NEXT
15030 ON ERROR GOTO 0