   50ONERRORGOTO80
   60IFF%<0CLOSE#0-F%
   80ONERROROFF
   90MODE3:A%=132:HIMEM=&FFFF AND(((USR&FFF4)AND&FFFFFF)/256)
  100V%=LOMEM:A%=130:H%=((USR&FFF4)AND&FFFFFF)/256
  105IFH%=0THENLOMEM=LOMEM+256:PROCasm(V%)ELSEPROCasm(&900)
  110IFH%=0A%=1000ELSEA%=500
  112S%=HIMEM-LOMEM-A%:IFS%<0S%=0
  115L%=LOMEM:CLEAR:LOMEM=L%
  120DIMX%20,W%&81:Y%=X%DIV256:IFH%=0DIMdata%256ELSEdata%=&A00
  122REPEAT:INPUT'"Debugger Version 1.23."'"Station to ""DEBUG"" :";$W%
  126F%=VAL($W%):IFF%THEN130
  127IF?W%=38F%=EVAL($W%)
  129IFNOTF%F%=-OPENIN($W%)
  130UNTILF%
  131IFF%<0A%=5:!X%=W%:CALL&FFDD:!&70=X%!2:!&74=!&70+X%!10
  133WIDTH160:@%=3:V%=HIMEM-S%:HIMEM=V%:A=0
  135PROChelp:D%=INKEY(0)
  141*K.0|LPROCfill|m
  142*K.1|LPROCex|m
  143*K.2PROCbasic|m
  144*K.3PROCsave|m
  145*K.4|LPROCfcb|m
  146*K.5|LREP.:PROCfcb:U.0|m
  147*K.6|m
  148*K.7I.N%:CLS:REP.:VDU30:PROCrxcbs(N%):U.0|m
  149*K.8|LPROCbcb|m
  150*K.9|LREP.:PROCbcb:U.0|m
  151END
  170:
  180DEFPROCtx:D%=200:REPEAT:A%=&10:CALL&FFF1
  230A%=50:REPEATUNTIL((USR&FFF4)AND&8000)=0
  240D%=D%-1:UNTIL((((USR&FFF4)AND&FF00)=0)ORD%=0)
  260IFD%=0PRINT"Tx failed":END
  270ENDPROC
  300:
  310DEFPROCpeek(from%,to%,at%)
  320X%!0=&81:GOTO450
  430DEFPROCpoke(from%,to%,at%)
  440IFF%<0PRINT"Can't":END
  445X%!0=&82
  450IFF%<0THEN480
  460X%!2=F%:X%!4=at%:X%!6=H%:X%!8=(at%+(to%-from%)):X%!10=H%
  470X%!12=from%:PROCtx:ENDPROC
  480IF(from%<!&70)OR(from%>!&74)OR(to%<!&70)OR(to%>!&74)PRINT"Outside saved area":END
  490?X%=0-F%:X%!1=at%:X%!5=to%-from%:X%!9=from%-!&70:A%=3:CALL&FFD1:ENDPROC
  500:
  540DEF PROCex
  560INPUT''"From :&"F$:M%=EVAL("&0"+F$):CLS
  570VDU30:PROCpeek(M%,M%+256,data%):PROCoff:CALLJ%,data%,M%
  587PRINT'" <Space> for next, <-> for previous, <Return> for same (once)"
  590PRINT" <?> for continuous, <~> for cancel continuous ?";:PROCon:F$=GET$
  600IFF$=" "THEN570
  601IFF$=CHR$13THENPROCw:GOTO570
  602IFF$="-"THENPROCw:PROCw:GOTO570
  603IFF$="~"THENPROCw:OSCLI"FX15,1":GOTO570
  605IFF$="?"THENPROCw:OSCLI"FX138,0,63":GOTO570
  610OSCLI"FX15,1":OSCLI"FX138,0,"+STR$(ASCF$):VDU30:GOTO560
  620ENDPROC
  630:
  640DEFPROCw:M%=(M%AND&FFFF0000)+((M%-256)AND&FFFF):ENDPROC
  650:
  660DEF PROCfill
  670@%=9:INPUT"From :&"F$:N%=EVAL("&0"+F$)
  680PROCpeek(N%,N%+2,data%)
  690PRINT~N%,~?data%":&";:INPUTG$
  700IFF$=""THEN750
  710IFF$="Q"ENDPROC
  730data%?0=EVAL("&0"+G$)
  740PROCpoke(N%,N%+2,data%)
  750N%=N%+1:GOTO680
  780:
  800DEFPROChelp
  810PRINT'"  *KEY 0 PROCfill"'"  *KEY 1 PROCex"
  820PRINT"  *KEY 2 PROCbasic"'"  *KEY 3 PROCsave"'"  *KEY 4 PROCfcb"
  830PRINT"  *KEY 5 Repeat PROCfcb"'"  *KEY 6"
  840PRINT"  *KEY 7 PROCrxcbs"
  850PRINT"  *KEY 8 PROCbcb"'"  *KEY 9 Repeat PROCbcb"''
  860ENDPROC
  900:
 1000DEFPROCon:VDU23,1,1;0;0;0;:ENDPROC
 1010DEFPROCoff:VDU23,1,0;0;0;0;:ENDPROC
 1390:
 1600DEF PROCasm(O%)
 1610FORQ%=0TO2STEP2
 1615P%=O%
 1630[OPT Q%
 1640.J% JSR s
 1775EQUW &D0D:EQUB &D:EQUS "  Address   ":LDX #0
 1800.l1 LDA &600,X:STA &80,X:INX:CPX #7:BNE l1:LDY #0:LDA (&81),Y
 1843STA &87:INY:LDA (&81),Y:STA &88:LDY #16:STY &80:LDX #0:LDA (&84,X):TAX
 1857.l2 TXA:AND #15:JSR Sph2:INX:DEY:BNE l2:JSR s
 1880EQUS "     Ascii data":EQUB 13:NOP
 1883.ln JSR s:EQUB 13:EQUS " ":NOP:LDY #3
 1891.l4 LDA (&84),Y:JSR I%:DEY:BPL l4:JSR s:EQUS " - ":NOP:LDY #0
 1917.l5 LDA (&87),Y:JSR Sph2:INY:CPY #16:BNE l5:JSR s:EQUS "  "
 1938NOP:LDY #0
 1944.l6 LDA (&87),Y:AND #&7F:CMP #32:BCC Dot:CMP #&7F:BEQ Dot
 1965.Prt JSR &FFEE:INY:CPY #16:BNE l6:BEQ n
 1977.Dot LDA #ASC".":BNE Prt
 1984.n LDY #0:LDA (&84),Y:CLC:ADC #16:STA (&84),Y:INY:LDA (&84),Y:ADC #0
 2001STA (&84),Y:LDA &87:CLC:ADC #16:STA &87:LDA &88:ADC #0:STA &88:DEC &80
 2023BNE ln:JMP &FFE7
 2030.Sph2 PHA:LDA #32:JSR &FFEE:PLA
 2080.I% PHA:LSRA:LSRA:LSRA:LSRA:JSR h1:PLA
 2160.h1 PHA:AND #15:CMP #10:BCC h11:ADC #6
 2220.h11 ADC #ASC"0":JSR &FFEE:PLA:RTS
 2260.s PLA:STA &8A:PLA:STA &8B:LDY #0
 2320.s1 INC &8A:BNE s3:INC &8B
 2360.s3 LDA (&8A),Y:BMI s2:JSR &FFE3:JMP s1
 2400.s2 JMP (&8A):]:NEXTQ%:ENDPROC
 4020:
 4030DEF PROCfcb
 4032PROCpeek(&FFFF009F,&FFFF00A0,data%)
 4035B%=&FFFF1000:IF(?data%)<&E THENB%=&FFFFC200
 4040PROCpeek(B%,B%+&70,data%)
 4050VDU30:PRINT''"Address of FCBs is &";~B%
 4055PRINT'"Internal  External"'"Handle    Handle  Type          PTR#       Seq  Wr  EOF#   Status   File server"
 4060PROCoff:FORO%=0TO15
 4070@%=2:PRINT"&";~O%+32;" = ";O%+32;
 4075E%=data%?(&30+O%):IFE%=0THENPRINTSPC(70);:GOTO4160
 4078G%=(data%?(&60+O%))
 4080IFFNBit(1)THENType$="Dir "ELSEType$="File"
 4081IFFNBit(5)=0 THEN 4090
 4082IFFNBit(2)THENType$=Type$+" U"ELSEType$=Type$+"  "
 4084IFFNBit(3)THENType$=Type$+" C"ELSEType$=Type$+"  "
 4086IFFNBit(4)THENType$=Type$+" L"ELSEType$=Type$+"  "
 4088GOTO4097
 4090IFFNBit(2)THENType$=Type$+" u"ELSEType$=Type$+"  "
 4092IFFNBit(3)THENType$=Type$+" c"ELSEType$=Type$+"  "
 4094IFFNBit(4)THENType$=Type$+" l"ELSEType$=Type$+"  "
 4097PRINTTAB(10);"&";:PROCH2(E%)
 4100PRINTTAB(16);Type$;
 4110PRINTTAB(30);"&";:PROCH2(data%?(&20+O%)):PROCH2(data%?(&10+O%)):PROCH2(data%?O%)
 4120PRINTTAB(35);FNBit(0);TAB(40);FNBit(7);TAB(45);FNBit(6);
 4145PRINTTAB(51);"&";:PROCH2(G%)
 4150PRINTTAB(58);(data%?(&50+O%));".";(data%?(&40+O%));
 4160PRINT:NEXT
 4162PROCpeek(B%-&1FE,B%-&1FA,data%)
 4163PROCpeek(B%+&72,B%+&75,data%+3):PRINT
 4164PRINTTAB(00);"URD=&";:PROCH2(data%?0):PRINT;"=>&";:PROCH2(data%?3):PRINT;"=";data%?3;
 4165PRINTTAB(20);"CSD=&";:PROCH2(data%?1):PRINT;"=>&";:PROCH2(data%?4):PRINT;"=";data%?4;
 4166PRINTTAB(40);"CSL=&";:PROCH2(data%?2):PRINT;"=>&";:PROCH2(data%?5):PRINT;"=";data%?5;
 4170PRINT:PROCon:ENDPROC
 4200:
 4210DEFPROCH2(A%):CALLI%:ENDPROC
 5000:
 5030DEF PROCbcb
 5040PROCpeek(&FFFF009F,&FFFF00A0,data%)
 5055B%=&FFFF1078:IF(?data%)<&E THENB%=&FFFFC278
 5060PROCpeek(B%,B%+&60,data%)
 5065L%=(&FF00 AND(B%+255))DIV256
 5070VDU30:PRINT''"Address of BCBs is &";~B%'
 5080PRINT"Buffer            BBC   Current"
 5090PRINT"Number Valid LRU Handle Sector  Length Last Wr2 Status Address"
 5100PROCoff:FORO%=0TO15
 5110@%=2:PRINT"&";:PROCH2(O%)
 5115G%=data%?(&40+O%)
 5120IFFNBit(6)=0THENPRINTSPC(50);:GOTO5700
 5130PRINTTAB(07);FNBit(1);
 5135PRINTTAB(12);FNBit(7);
 5140IFFNBit(1)=0THENPRINTSPC(50);:GOTO5700
 5150PRINTTAB(16);"&";:PROCH2(data%?(&30+O%))
 5200PRINTTAB(20);"&";:PROCH2(data%?(&10+O%)):PROCH2(data%?(O%))
 5205IFFNBit(5)=0THENVDU32,32:GOTO5220
 5210PRINTTAB(24);"&";:PROCH2(data%?(&20+O%))
 5220PRINTTAB(29);FNBit(5);
 5230PRINTTAB(34);FNBit(0);
 5240PRINTTAB(38);"&";:PROCH2(G%)
 5250PRINTTAB(43);"&FFFF";:PROCH2(L%+O%):VDU48,48
 5700PRINT:NEXTO%:PRINT:PROCon:ENDPROC
 5800:
 5900DEFFNBit(T%)=(G%AND2^T%)/2^T%
 5920:
 6000DEF PROCbasic:CLS:LOCAL@%:@%=&90F:PROCzero:PROCresint
 6013IFS%<(K%-E%+2)PRINT"Too many variables. by &";~(K%-E%+2-S%):ENDPROC
 6017PROCvars:PROCproc:PROCfn:ENDPROC
 6019:
 6020DEF PROCzero
 6021PROCpeek(0,256,data%)
 6022PRINT"PAGE=&";~(&100*(data%?&18))," ";
 6024PRINT"TOP=&";~((data%!&12)AND&FFFF)," ";
 6025E%=(data%!0)AND&FFFF:PRINT"LOMEM=&";~E%," ";
 6026K%=(data%!2)AND&FFFF:PRINT"VARTOP=&";~K%," ";
 6027PRINT"STACK=&";~((data%!4)AND&FFFF)
 6028PRINT"HIMEM=&";~((data%!6)AND&FFFF)," ";
 6029PRINT"IACC=&";~((data%!&2A)AND&FFFF)," ";
 6030ENDPROC
 6032:
 6033DEF PROCresint
 6035PROCpeek(&400,&480,W%):Z%=3+((!&482)AND&FFFF)
 6036PRINT"@%=&";~W%!0:FORR%=1TO27STEP 5
 6040FORB%=R%TOR%+4:IFB%>=27THEN6060
 6050PRINTCHR$(&40+B%);"%=&";~W%!(B%*4)," ";
 6060NEXTB%:PRINT:NEXTR%:PRINT:ENDPROC
 6062:
 6063DEF PROCvars
 6065PROCpeek(E%,K%+2,V%):PROCpeek(&482,&500,W%):G%=V%-E%
 6100FORR%=0TO57:PROClist:NEXTR%:PRINT:ENDPROC
 6107:
 6109DEF PROClist
 6110B%=(W%!(2*R%))AND&FFFF
 6120IFB%=0THENENDPROC
 6125REPEAT
 6127IFR%=58THENPRINT"PROC";
 6128IFR%=59THENPRINT"FN";
 6130IFR%<58THENPRINTCHR$(65+R%);
 6132Q%=B%+2:IF(G%?Q%)=0THEN6139
 6135REPEATPRINTCHR$(G%?Q%);:Q%=Q%+1:UNTIL(G%?Q%)=0
 6139B%=(G%!B%)AND&FFFF
 6140IF(G%?(Q%-1))=ASC"%"THENPRINT" = ";(G%!(Q%+1));" = &";~(G%!(Q%+1));:GOTO6150
 6142IF(G%?(Q%-1))=ASC"$"THENPROCestr(G%!(Q%+1)):GOTO6150
 6144IF(G%?(Q%-1))=ASC"("THENPROCeary(G%+Q%+1):GOTO6150
 6146PROCerl(G%+(Q%+1))
 6150PRINTSPC(32-(COUNT MOD30));:IFCOUNT>59THENPRINT
 6160UNTIL(B%AND&FF00)=0
 6165ENDPROC
 6168:
 6170DEF PROCproc
 6175PROCpeek(E%,K%+2,V%):PROCpeek(&482,&500,W%):G%=V%-E%
 6183R%=58:PROClist:PRINT:ENDPROC
 6196:
 6200DEF PROCfn
 6210PROCpeek(E%,K%+2,V%):PROCpeek(&482,&500,W%):G%=V%-E%
 6230R%=59:PROClist:PRINT:ENDPROC
 6261:
 6300DEFPROCerl(addr):LOCALP%:IFR%>57 THEN ENDPROC
 6310FORP%=0TO4:P%?Z%=P%?addr:NEXTP%
 6350PRINT;" = ";A;" = &";~A;:ENDPROC
 6400DEFPROCestr(blk):PRINT" = """;
 6405LOCALP%:IF(blk DIV &1000000)=0THENPRINT"""";:ENDPROC 
 6410FORP%=(blk AND&FFFF) TO (blk AND&FFFF)+(blk DIV &1000000)-1
 6420IF(G%?P%)<32THENPRINT".";:GOTO6430
 6422IF(G%?P%)>126THENPRINT".";:GOTO6430
 6424PRINTCHR$(G%?P%);
 6430NEXTP%:PRINT"""";:ENDPROC
 6435ENDPROC
 6440:
 6500DEF PROCeary(T%)
 6510?T%=?T%-1:C%=1:REPEAT
 6520PRINT;((T%!C%)AND&FFFF)-1;:?T%=(?T%)-2:C%=C%+2
 6530IF?T%>1 THEN PRINT;",";
 6540UNTIL?T%<=1:PRINT;")";:ENDPROC
 6999ENDPROC
 8000:
 8100DEF PROCsave
 8200IFF%<0 THEN PRINT"Can't save from file":END
 8300INPUT"Start address :&";$W%:!&70=EVAL("&0"+$W%)
 8350REPEAT:INPUT"End address :&";$W%:!&74=EVAL("&0"+$W%)
 8400UNTIL!&70 < !&74:INPUT"Filename :";$W%
 8450!X%=W%:X%!2=!&70:X%!6=!&70:X%!10=0:X%!14=!&74-!&70
 8500A%=7:CALL&FFDD:B%=256:U%=OPENUP$W%:REPEAT
 8550IF!&70+B%>!&74THENB%=!&74-!&70
 8600IFB%PROCpeek(!&70,B%+!&70,data%) ELSE GOTO8750
 8650FORC%=0TOB%-1:BPUT#U%,data%?C%:NEXTC%
 8700!&70=!&70+B%
 8750UNTILB%=0
 8800CLOSE#U%
 8900ENDPROC
 9000:
10000DEF PROCrxcbs(N%)
10005LOCAL @%:@%=5
10010PROCpeek(&FFFF009F,&FFFF00A0,data%)
10020U%=&100*(?data%) OR &FFFF0000
10040PRINT" Addr. Flag Port  Station          Start       End"
10050PROCpeek(&FFFF00C0,&FFFF00CC,data%)
10060PRINT~&C0,~?data%,~data%?1;TAB(20),~(&FFFF AND data%!2);:@%=10:PRINTTAB(28),~data%!4;TAB(40),~data%!8
10070FOR O%=0 TO N%+2
10075B%=U%+12*O%
10080PROCpeek(B%,B%+12,data%):@%=5
10086IFO%=3PRINT" The ""User"" blocks."
10090PRINT~(&FFFF AND B%),~?data%,~data%?1;TAB(20),~(&FFFF AND data%!2);:@%=10:PRINTTAB(28),~data%!4;TAB(40),~data%!8;
10094IFO%=0PRINT" The ""Printer"" block."
10095IFO%=1PRINT" The ""Remote"" block."
10096IFO%=2PRINT" The ""DoFSop"" block."
10097IFO%>2PRINT
10100NEXTO%:PRINT:ENDPROC
