 MSB OFF
       ORG $800
KST JSR UVASIOI
 JMP KSTART
UVASLOT DFB $20
UVASTAT DFB $84
UVADATA DFB $85
UVASTATR DFB 1
UVASTATT DFB 2
UVAMISC DFB $11
UVASIOI LDA UVASTATR
 STA UVATEL4+1
 LDA UVASTATT
 STA UVATEL5+1
 LDA UVADATA
 STA UVATEL1+1
 STA UVATEL2+1
 LDA UVASTAT
 STA UVATEL3+1
 STA TELPP1+1
 STA UVASSTAT+1
 LDA #3
 LDX UVASLOT
 JSR UVASSTAT
 LDA UVAMISC
UVASSTAT STA KERPST,X
 RTS
 DS 50
TELCP LDX UVASLOT
UVATEL3 LDA KERPST,X
UVATEL4 AND #$01
 BEQ TELNC
 LDA #TRUE
 RTS
TELNC LDA #FALSE
 RTS
TELGPC LDX UVASLOT
UVATEL1 LDA KERPCH,X
 AND #$7F
 RTS
TELPPC PHA
 LDX UVASLOT
TELPP1 LDA KERPST,X
UVATEL5 AND #$02
 BEQ TELPP1
 PLA
UVATEL2 STA KERPCH,X
 RTS
FTAPPL EQU $01
FTASER EQU $01
FTHAYS EQU $02
FTCOM EQU FTAPPL
FTCDEV EQU FTASER
KERSLO EQU $C200
KERCSR EQU KERSLO/256
KERCSI EQU KERCSR*16-$0C00
RDKEY EQU $FD0C
KEYIN EQU $FD1B
COUT EQU $FDED
COUT1 EQU $FDF0
SETIO1 EQU $FE89
SETIO2 EQU $FE93
PRBL2 EQU $F94A
PRBL3 EQU $F94C
PRBYTE EQU $FDDA
PRNTYX EQU $F940
PRNTAX EQU $F941
SCRL3 EQU $FC95
BELL EQU $FF3A
HOME EQU $FC58
LFEED EQU $FC66
UPLINE EQU $FC1A
ADVANC EQU $FBF4
BSP EQU $FC10
CLREOL EQU $FC9C
CLREOP EQU $FC42
CLREOZ EQU $FC9E
VTAB EQU $FC22
VTABZ EQU $FC24
DOS EQU $03D0
KBD EQU $C000
KBDSTR EQU $C010
SLOT EQU $C200
A1L EQU $3C
A1H EQU $3D
A2L EQU $3E
A2H EQU $3F
A3L EQU $40
A3H EQU $41
A4L EQU $42
A4H EQU $43
A5L EQU $44
A5H EQU $45
NUL EQU $00
SOH EQU $01
BS EQU $08
TAB EQU $09
LF EQU $0A
FFD EQU $0C
CR EQU $0D
CTRLU EQU $15
CTRLX EQU $18
ESC EQU $1B
SP EQU $20
DEL EQU $7F
HBS EQU $88
HTAB EQU $89
HCR EQU $8D
HLF EQU $8A
HFFD EQU $8C
HCTRLU EQU $95
HCTRLX EQU $98
HESC EQU $9B
HSPACE EQU $A0
HQUEST EQU $BF
HDEL EQU $FF
WNDLFT EQU $20
WNDWTH EQU $21
WNDTOP EQU $22
WNDBTM EQU $23
CH EQU $24
CV EQU $25
BASL EQU $26
BASH EQU $27
BAS2L EQU $2A
BAS2H EQU $2B
CMINI EQU 0
CMKEY EQU 1
CMIFI EQU 2
CMOFI EQU 3
CMCFM EQU 4
CMNUM EQU 5
CMSWI EQU 6
CMFLS EQU 7
SADDR EQU $00
CM.RTY EQU $02
CM.BFP EQU $04
CM.PTR EQU $06
CM.INC EQU $08
CM.CNT EQU $09
CMINF1 EQU $0A
CMINF2 EQU $0C
CMKPTR EQU $0E
CMSPTR EQU $10
CMSPT2 EQU $12
CMSPT3 EQU $14
CMHPTR EQU $16
CMPTAB EQU $18
CMFCB EQU $1A
CMFCB2 EQU $1C
COMND JMP COMAND
 JMP MUL16
CRLF DFB $8D,$8A,$00
CMBUF DS $80
PRMT ASC 'KERMIT-65>' 0
 DFB 0
LPRMT EQU .-PRMT
SAVEA DFB 0
SAVEX DFB 0
SAVEY DFB 0
CMBASE DFB 0
CMMRES DS 4
CMINTG DS 4
CMFLTP DS 6
CMFLEN DFB 0
CMCDRV DFB 0
CMOSTP DW 0
CMRPRS DW 0
CMAFLG DFB 0
CMCCNT DFB 0
CMSFLG DFB 0
CMSTAT DFB 0
CMKYLN DFB 0
CMTLEN DFB 0
CMSCRS DFB 0
CMENTR DFB 0
KEYLEN DFB 0
CMWRK1 DFB 0
CMWRK2 DFB 0
CMWRK3 DFB 0
CMWRK4 DFB 0
HCH DFB 0
HCV DFB 0
TRUE EQU $01
FALSE EQU $00
ON EQU $01
OFF EQU $00
YES EQU $01
NO EQU $00
PROMPT PLA
 STA CMRPRS
 PLA
 STA CMRPRS+1
 PHA
 LDA CMRPRS
 PHA
 CLC
 ADC #$01
 STA CMRPRS
 LDA CMRPRS+1
 ADC #$00
 STA CMRPRS+1
 TSX
 STX CMOSTP
 LDA #PRMT
 STA CM.RTY
 LDA #<PRMT
 STA CM.RTY+1
 LDA #CMBUF
 STA CM.BFP
 STA CM.PTR
 LDA #<CMBUF
 STA CM.BFP+1
 STA CM.PTR+1
 LDA #$00
 STA CMAFLG
 STA CMCCNT
 STA CMSFLG
 JSR PRCRLF
 LDX CM.RTY
 LDY CM.RTY+1
 JSR PRSTR
 RTS
REPARS LDX CMOSTP
 TXS
 LDA #CMBUF
 STA CM.PTR
 LDA #<CMBUF
 STA CM.PTR+1
 LDA #$00
 STA CMSFLG
 JMP (CMRPRS)
PRSERR LDX CMOSTP
 TXS
 LDA #CMBUF
 STA CM.BFP
 STA CM.PTR
 LDA #<CMBUF
 STA CM.BFP+1
 STA CM.PTR+1
 LDA #$00
 STA CMAFLG
 STA CMCCNT
 STA CMSFLG
 JSR PRCRLF
 LDX #PRMT
 LDY #<PRMT
 JSR PRSTR
 JMP (CMRPRS)
COMAND STA CMSTAT
 CMP #CMINI
 BNE COMN0
 JMP PROMPT
COMN0 JSR CMINBF
 CMP #CMCFM
 BNE COMN1
 JMP CMCFRM
COMN1 CMP #CMKEY
 BNE COMN2
 JMP CMKEYW
COMN2 CMP #CMIFI
 BNE COMN3
 JMP CMIFIL
COMN3 CMP #CMOFI
 BNE COMN4
 JMP CMOFIL
COMN4 CMP #CMSWI
 BNE COMN5
 JMP CMSWIT
COMN5 CMP #CMNUM
 BNE COMN6
 JMP CMINUM
COMN6 CMP #CMFLS
 BNE COMN7
 JMP CMFLOT
COMN7 LDX #CMER00
 LDY #<CMER00
 JSR PRSTR
 LDA #$04
 RTS
CMCFRM LDA CM.PTR
 PHA
 LDA CM.PTR+1
 PHA
CMCFR0 JSR CMGTCH
 CMP #$00
 BPL CMCFRR
 AND #$7F
 CMP #ESC
 BNE CMCFR2
 JSR BELL
 LDA #$00
 STA CMAFLG
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 STA CM.PTR
 BCS CMCFR1
 DEC CM.BFP+1
CMCFR1 LDA CM.BFP+1
 STA CM.PTR+1
 DEC CMCCNT
 JMP CMCFR0
CMCFR2 CMP #'?
 BNE CMCFR3
 ORA #$80
 JSR COUT
 LDX #CMIN00
 LDY #<CMIN00
 JSR PRSTR
 JSR PRCRLF
 LDX #PRMT
 LDY #<PRMT
 JSR PRSTR
 LDA #$00
 LDY #$00
 STA (CM.PTR),Y
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 LDA CM.BFP+1
 SBC #$00
 STA CM.BFP+1
 LDX #CMBUF
 LDY #<CMBUF
 JSR PRSTR
 LDA #$00
 STA CMAFLG
 JMP REPARS
CMCFR3 CMP #FFD
 BNE CMCFR4
 JSR HOME
CMCFR4 PLA
 PLA
 JMP RSKP
CMCFRR PLA
 STA CM.PTR+1
 PLA
 STA CM.PTR
 RTS
 DFB 0
CMKEYW LDA CM.PTR
 PHA
 LDA CM.PTR+1
 PHA
 LDA CMINF1
 STA CMPTAB
 CLC
 ADC #$01
 STA CMKPTR
 LDA CMINF1+1
 STA CMPTAB+1
 BCC CMKEY1
 ADC #$00
CMKEY1 STA CMKPTR+1
 LDY #$00
 LDA (CMPTAB),Y
 STA CMENTR
 JSR CMGTCH
 CMP #$00
 BMI CMKY11
 SEC
 LDA CM.PTR
 SBC #$01
 STA CM.PTR
 STA CMSPTR
 LDA CM.PTR+1
 SBC #$00
 STA CM.PTR+1
 STA CMSPTR+1
 JMP CMKEY2
CMKY11 LDA CM.PTR
 STA CMSPTR
 LDA CM.PTR+1
 STA CMSPTR+1
CMKEY2 LDA CMENTR
 CMP #$00
 BNE CMKY21
 PLA
 STA CM.PTR+1
 PLA
 STA CM.PTR
 RTS
CMKY21 LDY #$00
 LDA (CMKPTR),Y
 STA KEYLEN
 LDA CMKPTR
 STA CMSPT2
 LDA CMKPTR+1
 STA CMSPT2+1
 INC CMKPTR
 BNE CMKEY3
 INC CMKPTR+1
CMKEY3 DEC KEYLEN
 LDA KEYLEN
 CMP #$FF
 BPL CMK3A
 JMP CMKEY5
CMK3A JSR CMGTCH
 CMP #$00
 BMI CMK3B
 JMP CMKEY4
CMK3B AND #$7F
 CMP #'?
 BNE CMKY31
 ORA #$80
 JSR COUT
 LDA #$00
 STA CMAFLG
 LDA CMSTAT
 CMP #CMSWI
 BEQ CMK3B1
 LDX #CMIN01
 LDY #<CMIN01
 JMP CMK3B2
CMK3B1 LDX #CMIN02
 LDY #<CMIN02
CMK3B2 JSR PRSTR
 JSR PRCRLF
 JSR CMKTP
 JSR PRCRLF
 LDX #PRMT
 LDY #<PRMT
 JSR PRSTR
 LDA #$00
 LDY #$00
 STA (CM.PTR),Y
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 BCS CMKY3A
 DEC CM.BFP+1
CMKY3A LDX #CMBUF
 LDY #<CMBUF
 JSR PRSTR
 JMP REPARS
CMKY31 CMP #ESC
 BEQ CMK3C
 JMP CMKY35
CMK3C LDA #$00
 STA CMAFLG
 LDA KEYLEN
 PHA
 LDA CMENTR
 PHA
 LDA CMKPTR
 PHA
 LDA CMKPTR+1
 PHA
 JSR CMAMBG
  JMP CMKY32
 JSR BELL
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 STA CM.PTR
 BCS CMKY3B
 DEC CM.BFP+1
CMKY3B LDA CM.BFP+1
 STA CM.PTR+1
 DEC CMCCNT
 PLA
 STA CMKPTR+1
 PLA
 STA CMKPTR
 PLA
 STA CMENTR
 PLA
 STA KEYLEN
 INC KEYLEN
 JMP CMKEY3
CMKY32 LDY #$00
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 STA CM.PTR
 BCS CMK32C
 DEC CM.BFP+1
CMK32C LDA CM.BFP+1
 STA CM.PTR+1
 PLA
 STA CMKPTR+1
 PLA
 STA CMKPTR
 PHA
 LDA CMKPTR+1
 PHA
CMKY33 LDA (CMKPTR),Y
 CMP #$00
 BEQ CMKY34
 TAX
 CLC
 LDA CMKPTR
 ADC #$01
 STA CMKPTR
 BCC CMKY3C
 INC CMKPTR+1
CMKY3C TXA
 ORA #$80
 STA (CM.PTR),Y
 CLC
 LDA CM.PTR
 ADC #$01
 STA CM.PTR
 BCC CMKY3D
 INC CM.PTR+1
CMKY3D INC CMCCNT
 JMP CMKY33
CMKY34 INC CMCCNT
 LDA #$A0
 STA (CM.PTR),Y
 LDX CM.BFP
 LDY CM.BFP+1
 CLC
 LDA CM.PTR
 ADC #$01
 STA CM.PTR
 STA CM.BFP
 BCC CMKY3E
 INC CM.PTR+1
CMKY3E LDA CM.PTR+1
 STA CM.BFP+1
 STY SAVEY
 LDA #$00
 LDY #$00
 STA (CM.PTR),Y
 LDY SAVEY
 JSR PRSTR
 PLA
 STA CMKPTR+1
 PLA
 STA CMKPTR
 PLA
 STA CMENTR
 PLA
 STA KEYLEN
 JMP CMKY37
CMKY35 LDA CMKPTR
 PHA
 LDA CMKPTR+1
 PHA
 LDA KEYLEN
 PHA
 JSR CMAMBG
  JMP CMKY36
 LDX #CMER01
 LDY #<CMER01
 JSR PRSTR
 JMP PRSERR
CMKY36 PLA
 STA KEYLEN
 PLA
 STA CMKPTR+1
 PLA
 STA CMKPTR
CMKY37 INC KEYLEN
 INC KEYLEN
 CLC
 LDA CMKPTR
 ADC KEYLEN
 STA CMKPTR
 BCC CMKY3F
 INC CMKPTR+1
CMKY3F LDY #$00
 LDA (CMKPTR),Y
 TAX
 INY
 LDA (CMKPTR),Y
 TAY
 PLA
 PLA
 JMP RSKP
CMKEY4 CMP #'A
 BMI CMKY41
 CMP #'Z'+1
 BPL CMKY41
 AND #$5F
CMKY41 STA CMWRK3
 LDY #$00
 LDA (CMKPTR),Y
 STA CMWRK4
 CLC
 LDA CMKPTR
 ADC #$01
 STA CMKPTR
 BCC CMKY4A
 INC CMKPTR+1
CMKY4A LDA CMWRK3
 CMP CMWRK4
 BNE CMKEY5
 JMP CMKEY3
CMKEY5 INC KEYLEN
 INC KEYLEN
 INC KEYLEN
 CLC
 LDA CMKPTR
 ADC KEYLEN
 STA CMKPTR
 BCC CMKY5A
 INC CMKPTR+1
CMKY5A DEC CMENTR
 LDA CMSPTR
 STA CM.PTR
 LDA CMSPTR+1
 STA CM.PTR+1
 JMP CMKEY2
CMAMBG DEC CMENTR
 BPL CMA1
 RTS
CMA1 INC KEYLEN
 LDA KEYLEN
 STA CMWRK3
 CLC
 ADC #$03
 STA KEYLEN
 CLC
 LDA CMKPTR
 ADC KEYLEN
 STA CMKPTR
 BCC CMA2
 INC CMKPTR+1
CMA2 LDY #$00
 LDA (CMKPTR),Y
 STA CMWRK4
 CLC
 LDA CMKPTR
 ADC #$01
 STA CMKPTR
 BCC CMA3
 INC CMKPTR+1
CMA3 LDA (CMSPT2),Y
 SEC
 SBC CMWRK3
 STA CMTLEN
 CMP CMWRK4
 BMI CMAMB0
 RTS
CMAMB0 LDY #$00
CMAMB1 DEC CMTLEN
 BPL CMA4
 JMP RSKP
CMA4 LDA (CMKPTR),Y
 STA CMWRK3
 LDA (CMSPTR),Y
 INY
 CMP #'A
 BMI CMAMB2
 CMP #'Z'+1
 BPL CMAMB2
 AND #$5F
CMAMB2 AND #$7F
 CMP CMWRK3
 BEQ CMAMB1
 RTS
CMKTP LDA CMPTAB
 STA CMINF2
 LDA CMPTAB+1
 STA CMINF2+1
 LDY #$00
 STY CMSCRS
 STY CMWRK3
 LDA (CMINF2),Y
 STA CMWRK1
 SEC
 LDA CM.PTR
 SBC CMSPTR
 STA CMTLEN
 CLC
 LDA CMINF2
 ADC #$01
 STA CMINF2
 BCC CMKTP1
 INC CMINF2+1
CMKTP1 DEC CMWRK1
 LDA CMWRK1
 BMI CMKDON
 LDA (CMINF2),Y
 STA CMKYLN
 CLC
 LDA CMINF2
 ADC #$01
 STA CMINF2
 BCC CMKTP2
 INC CMINF2+1
CMKTP2 LDA CMTLEN
 BEQ CMKTP3
CMKP21 LDA (CMINF2),Y
 ORA #$80
 CMP (CMSPTR),Y
 BNE CMADK
 INY
 CPY CMTLEN
 BMI CMKP21
CMKTP3 JSR CMPRK
CMADK INC CMKYLN
 INC CMKYLN
 INC CMKYLN
 CLC
 LDA CMINF2
 ADC CMKYLN
 STA CMINF2
 BCC CMADK2
 INC CMINF2+1
CMADK2 LDY #$00
 JMP CMKTP1
CMKDON LDA CMWRK3
 BNE CMKDN2
 LDA CMSTAT
 CMP #CMSWI
 BEQ CMKDSE
 LDX #CMER03
 LDY #<CMER03
 JMP CMKDN1
CMKDSE LDX #CMER04
 LDY #<CMER04
CMKDN1 JSR PRSTR
 JSR PRCRLF
CMKDN2 LDA CMSCRS
 BEQ CMKDN3
 JSR PRCRLF
CMKDN3 RTS
CMPRK LDA #ON
 STA CMWRK3
 LDA CMSTAT
 CMP #CMSWI
 BNE CMPR2
 LDA #'/
 ORA #$80
 JSR COUT
CMPR2 LDX CMINF2
 LDY CMINF2+1
 JSR PRSTR
 LDA CMSCRS
 BNE CMPRMS
 JSR CLREOL
 LDA #$14
 STA CH
 JMP CMPRDN
CMPRMS JSR PRCRLF
CMPRDN LDA CMSCRS
 EOR #$01
 STA CMSCRS
 RTS
CMSWIT LDA CM.PTR
 PHA
 LDA CM.PTR+1
 PHA
CMSWI0 JSR CMGTCH
 CMP #$00
 BMI CMSWI1
 JMP CMSWI3
CMSWI1 AND #$7F
 CMP #'?
 BNE CMSW12
 ORA #$80
 JSR COUT
 LDA #$00
 STA CMAFLG
 LDX #CMIN02
 LDY #<CMIN02
 JSR PRSTR
 JSR PRCRLF
 JSR CMKTP
 JSR PRCRLF
 LDX #PRMT
 LDY #<PRMT
 JSR PRSTR
 LDA #$00
 LDY #$00
 STA (CM.PTR),Y
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 BCS CMSW1A
 DEC CM.BFP+1
CMSW1A LDX #CMBUF
 LDY #<CMBUF
 JSR PRSTR
 JMP REPARS
CMSW12 CMP #ESC
 BEQ CMSW2A
 JMP CMSWI2
CMSW2A LDA #$00
 STA CMAFLG
 LDY #$00
 LDA (CMINF1),Y
 CMP #$02
 BMI CMSW2C
 JSR BELL
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 STA CM.PTR
 BCS CMSW2B
 DEC CM.BFP+1
CMSW2B LDA CM.BFP+1
 STA CM.PTR+1
 DEC CMCCNT
 JMP CMSWI0
CMSW2C LDA #'/
 ORA #$80
 JSR COUT
 CLC
 LDA CMINF1
 ADC #$02
 STA CMKPTR
 LDA CMINF1+1
 BCC CMSW2D
 ADC #$00
CMSW2D STA CMKPTR+1
 LDY #$00
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 BCS CMSW2E
 DEC CM.BFP+1
CMSW2E LDA (CMKPTR),Y
 CMP #$00
 BEQ CMSW13
 TAX
 CLC
 LDA CMKPTR
 ADC #$01
 STA CMKPTR
 BCC CMSW2F
 INC CMKPTR+1
CMSW2F TXA
 STA (CM.PTR),Y
 CLC
 LDA CM.PTR
 ADC #$01
 STA CM.PTR
 BCC CMSW2G
 INC CM.PTR+1
CMSW2G INC CMCCNT
 JMP CMSW2E
CMSW13 INC CMCCNT
 LDA #$00
 STA (CM.PTR),Y
 LDX CM.BFP
 LDY CM.BFP+1
 CLC
 LDA CM.PTR
 ADC #$01
 STA CM.PTR
 STA CM.BFP
 BCC CMSW3A
 INC CM.PTR+1
CMSW3A LDA CM.PTR+1
 STA CM.BFP+1
 JSR PRSTR
 LDX #$01
 JSR PRBL2
CMSW14 CLC
 LDA CMKPTR
 ADC #$01
 STA CMKPTR
 BCC CMSW4A
 INC CMKPTR+1
CMSW4A LDY #$00
 LDA (CMKPTR),Y
 TAX
 INY
 LDA (CMKPTR),Y
 TAY
 PLA
 PLA
 JMP RSKP
CMSWI2 LDY #$00
 LDA (CMINF1),Y
 CMP #$02
 BMI CMSW21
 LDX #CMER01
 LDY #<CMER01
 JSR PRSTR
 JMP PRSERR
CMSW21 INY
 LDA (CMINF1),Y
 STA KEYLEN
 LDA CMINF1+1
 STA CMKPTR+1
 CLC
 LDA CMINF1
 ADC KEYLEN
 ADC #$02
 STA CMKPTR
 BCC CMSW22
 INC CMKPTR+1
CMSW22 JMP CMSW4A
CMSWI3 CMP #'/
 BEQ CMSWI4
 TAX
 LDA #$00
 PLA
 STA CM.PTR+1
 PLA
 STA CM.PTR
 RTS
CMSWI4 JSR CMKEYW
  JMP CMSWI5
 PLA
 PLA
 JMP RSKP
CMSWI5 PLA
 STA CM.PTR+1
 PLA
 STA CM.PTR
 RTS
CMIFIL LDA CM.PTR
 PHA
 LDA CM.PTR+1
 PHA
 LDA #$00
 STA CMFLEN
 LDA CMINF1
 STA CMFCB
 STA CMFCB2
 LDA CMINF1+1
 STA CMFCB+1
 STA CMFCB2+1
CMIFL0 LDY #$00
 LDA #'
 ORA #$80
CMIFI0 STA (CMFCB),Y
 INY
 CPY #MXFNL+1
 BPL CMIFI1
 JMP CMIFI0
CMIFI1 JSR CMGTCH
 CMP #$00
 BPL CMIFI2
 AND #$7F
 CMP #'?
 BNE CMIF12
 ORA #$80
 JSR COUT
 LDY #$00
 STY CMAFLG
 LDX #CMIN03
 LDY #<CMIN03
 JSR PRSTR
 JSR PRCRLF
 LDX #PRMT
 LDY #<PRMT
 JSR PRSTR
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 BCS CMIF11
 DEC CM.BFP+1
CMIF11 DEC CMCCNT
 LDY #$00
 LDA #$00
 STA (CM.BFP),Y
 LDX #CMBUF
 LDY #<CMBUF
 JSR PRSTR
 JMP CMIFI1
CMIF12 CMP #ESC
 BNE CMIF13
 LDA #$00
 STA CMAFLG
 JSR BELL
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 STA CM.PTR
 LDA CM.BFP+1
 SBC #$00
 STA CM.BFP+1
 STA CM.PTR+1
 DEC CMCCNT
 JMP REPARS
CMIF13 LDA CMFLEN
 CMP #$00
 BNE CMIF14
 JMP CMIFI9
CMIF14 CMP #MXFNL+1
 BMI CMIF15
 JMP CMIFI9
CMIF15 LDY CMFLEN
 LDA #NUL
 STA (CMFCB2),Y
 PLA
 PLA
 JMP RSKP
CMIFI2 CMP #'!
 BMI CMIFI9
 CMP #'Z'+1
 BPL CMIFI9
 CMP #'A
 BMI CMIFI8
 AND #$5F
CMIFI8 LDY #$00
 STA (CMFCB2),Y
 CLC
 LDA CMFCB2
 ADC #$01
 STA CMFCB2
 LDA CMFCB2+1
 ADC #$00
 STA CMFCB2+1
 INC CMFLEN
 JMP CMIFI1
CMIFI9 PLA
 STA CM.PTR+1
 PLA
 STA CM.PTR
 RTS
CMOFIL JMP CMIFIL
CMINUM LDA CM.PTR
 PHA
 LDA CM.PTR+1
 PHA
 CPX #$11
 BMI CMIN1
 JMP CMINE1
CMIN1 CPX #$02
 BPL CMIN2
 JMP CMINE1
CMIN2 STX CMBASE
 LDA #$00
 STA CMMRES
 STA CMMRES+1
 STA CMMRES+2
 STA CMMRES+3
 STA CMINTG
 STA CMINTG+1
 STA CMINTG+2
 STA CMINTG+3
CMINM1 JSR CMGTCH
 CMP #$00
 BMI CMIN1A
 JMP CMINM4
CMIN1A AND #$7F
 CMP #ESC
 BNE CMINM2
 JSR BELL
 LDA #$00
 STA CMAFLG
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 STA CM.PTR
 BCS CMIN11
 DEC CM.BFP+1
CMIN11 LDA CM.BFP+1
 STA CM.PTR+1
 DEC CMCCNT
 JMP CMINM1
CMINM2 CMP #'?
 BNE CMINM3
 ORA #$80
 JSR COUT
 LDX #CMIN05
 LDY #<CMIN05
 JSR PRSTR
 LDA CMBASE
 CMP #$0A
 BMI CMIN21
 CLC
 LDA #$01
 ADC #$B0
 JSR COUT
 LDA CMBASE
 SEC
 SBC #$0A
CMIN21 CLC
 ADC #$B0
 JSR COUT
 JSR PRCRLF
 LDX #PRMT
 LDY #<PRMT
 JSR PRSTR
 LDA #$00
 LDY #$00
 STA (CM.PTR),Y
 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 BCS CMIN22
 DEC CM.BFP+1
CMIN22 LDX #CMBUF
 LDY #<CMBUF
 JSR PRSTR
 LDA #$00
 STA CMAFLG
 JMP REPARS
CMINM3 SEC
 LDA CM.BFP
 SBC #$01
 STA CM.BFP
 STA CM.PTR
 BCS CMIN31
 DEC CM.BFP+1
CMIN31 LDA CM.BFP+1
 STA CM.PTR+1
 LDA CMMRES
 STA CMINTG
 LDA CMMRES+1
 STA CMINTG+1
 PLA
 PLA
 JMP RSKP
CMINM4 CMP #$40
 BMI CMIN41
 SEC
 SBC #$07
CMIN41 SEC
 SBC #$30
 CMP #$00
 BMI CMINM5
 CMP CMBASE
 BMI CMINM6
CMINM5 PLA
 STA CM.PTR+1
 PLA
 STA CM.PTR
 RTS
CMINM6 PHA
 LDA CMMRES+1
 PHA
 LDA CMMRES
 PHA
 LDA #$00
 PHA
 LDA CMBASE
 PHA
 JSR MUL16
 PLA
 STA CMMRES
 PLA
 STA CMMRES+1
 PLA
 CLC
 ADC CMMRES
 STA CMMRES
 LDA CMMRES+1
 ADC #$00
 STA CMMRES+1
 BCS CMINE2
 JMP CMINM1
CMINE1 LDX #CMER06
 LDY #<CMER06
 JSR PRSTR
 JMP PRSERR
CMINE2 LDX #CMER07
 LDY #<CMER07
 JSR PRSTR
 JMP PRSERR
CMFLOT RTS
CMINBF PHA
 TXA
 PHA
 TYA
 PHA
 PHP
 LDY #$00
 LDA CMAFLG
 CMP #$00
 BEQ CMINB1
 JMP CMINB9
CMINB1 INC CMCCNT
 JSR RDKEY
 LDY #$00
 STA (CM.BFP),Y
 TAX
 CLC
 LDA CM.BFP
 ADC #$01
 STA CM.BFP
 BCC CMNB11
 INC CM.BFP+1
CMNB11 TXA
 CMP #<HCTRLU
 BNE CMINB2
CMNB12 JSR SCRL3
 LDX #PRMT
 LDY #<PRMT
 LDA #$00
 STA CH
 JSR PRSTR
 JSR CLREOL
 LDA #CMBUF
 STA CM.BFP
 LDA #<CMBUF
 STA CM.BFP+1
 LDA #$00
 STA CMCCNT
 JMP REPARS
CMINB2 CMP #HBS
 BEQ CMINB3
 CMP #HDEL
 BNE CMINB4
CMINB3 DEC CH
 JSR CLREOL
 DEC CMCCNT
 DEC CMCCNT
 LDA CMCCNT
 CMP #$00
 BPL CMNB32
 JSR BELL
 JMP CMNB12
CMNB32 SEC
 LDA CM.BFP
 SBC #$02
 STA CM.BFP
 BCS CMNB33
 DEC CM.BFP+1
CMNB33 JMP REPARS
CMINB4 CMP #HQUEST
 BEQ CMINB6
 CMP #HESC
 BEQ CMINB6
 CMP #HCR
 BEQ CMINB5
 CMP #HLF
 BEQ CMINB5
 CMP #HFFD
 BNE CMINB7
 JSR HOME
CMINB5 LDA CMCCNT
 CMP #$01
 BNE CMINB6
 JMP PRSERR
CMINB6 LDA #$FF
 STA CMAFLG
 JMP CMINB9
CMINB7 CMP #'
 BNE CMNB71
 JSR COUT
 JMP CMINB1
CMNB71 CMP #HTAB
 BNE CMNB72
 JSR COUT
 JMP CMINB1
CMNB72 JSR COUT
 JMP CMINB1
CMINB9 DEC CMCCNT
 PLP
 PLA
 TAY
 PLA
 TAX
 PLA
 RTS
CMGTCH LDY #$00
 LDA CMAFLG
 CMP #$00
 BNE CMGT1
 JSR CMINBF
CMGT1 LDA (CM.PTR),Y
 TAX
 CLC
 LDA CM.PTR
 ADC #$01
 STA CM.PTR
 BCC CMGT2
 INC CM.PTR+1
CMGT2 TXA
 CMP #HSPACE
 BEQ CMGTC2
 CMP #HTAB
 BNE CMGTC3
CMGTC2 LDA CMSFLG
 CMP #$00
 BNE CMGTCH
 LDA #$FF
 STA CMSFLG
 LDA #HSPACE
 JMP CMGTC5
CMGTC3 PHP
 PHA
 LDA #$00
 STA CMSFLG
 PLA
 PLP
 CMP #HESC
 BEQ CMGTC5
 CMP #HQUEST
 BEQ CMGTC4
 CMP #HCR
 BEQ CMGTC4
 CMP #HLF
 BEQ CMGTC4
 CMP #HFFD
 BEQ CMGTC4
 AND #$7F
 RTS
CMGTC4 TAX
 SEC
 LDA CM.PTR
 SBC #$01
 STA CM.PTR
 BCS CMGTC5
 DEC CM.PTR+1
CMGTC5 TXA
 ORA #$80
 RTS
PRCRLF LDA #HCR
 JSR COUT
 RTS
PRSTR STX SADDR
 STY SADDR+1
 LDY #$00
PRST1 LDA (SADDR),Y
 BEQ PRSDON
 ORA #$80
 JSR DELY
 INY
 BNE PRST2
 INC SADDR+1
PRST2 JMP PRST1
PRSDON RTS
DELY PHA
 LDA #$32
 JSR $FCA8
 PLA
 JSR COUT
 RTS
MUL16 PLA
 STA RTADDR
 PLA
 STA RTADDR+1
 PLA
 STA MLIER
 PLA
 STA MLIER+1
 PLA
 STA MCAND
 PLA
 STA MCAND+1
 LDA #$00
 STA HIPROD
 STA HIPROD+1
 LDX #17
 CLC
MULLP ROR HIPROD+1
 ROR HIPROD
 ROR MLIER+1
 ROR MLIER
 BCC DECCNT
 CLC
 LDA MCAND
 ADC HIPROD
 STA HIPROD
 LDA MCAND+1
 ADC HIPROD+1
 STA HIPROD+1
DECCNT DEX
 BNE MULLP
 LDA MLIER+1
 PHA
 LDA MLIER
 PHA
 LDA RTADDR+1
 PHA
 LDA RTADDR
 PHA
 RTS
MCAND DS 2
MLIER DS 2
HIPROD DS 2
RTADDR DS 2
RSKP STA SAVEA
 STX SAVEX
 STY SAVEY
 STA CMINF2
 PLA
 TAX
 PLA
 TAY
 TXA
 CLC
 ADC #$04
 BCC RSKP2
 INY
RSKP2 STA SADDR
 STY SADDR+1
 LDA CMINF2
 LDA SAVEA
 LDX SAVEX
 LDY SAVEY
 JMP (SADDR)
CMER00 DFB HCR,HLF
 ASC '?PROGRAM ERROR  INVALID COMND CALL' 1
 DFB 0
CMER01 DFB HCR,HLF
 ASC '?AMBIGUOUS' 1
 DFB 0
CMER02 DFB HCR,HLF
 ASC '?ILLEGAL INPUT FILE SPEC' 1
 DFB 0
CMER03 DFB HCR,HLF
 ASC '?NO KEYWORDS MATCH THIS PREFIX' 1
 DFB 0
CMER04 DFB HCR,HLF
 ASC '?NO SWITCHES MATCH THIS PREFIX' 1
 DFB 0
CMER05 DFB HCR,HLF
 ASC '?BAD CHARACTER IN INTEGER NUMBER' 1
 DFB 0
CMER06 DFB HCR,HLF
 ASC '?BASE OF INTEGER OUT OF RANGE' 1
 DFB 0
CMER07 DFB HCR,HLF
 ASC '?OVERFLOW WHILE READING INTEGER NUMBER' 1
 DFB 0
CMIN00 ASC ' CONFIRM WITH CARRIAGE RETURN' 1
 DFB 0
CMIN01 ASC ' KEYWORD, ONE OF THE FOLLOWING' 1
 DFB 0
CMIN02 ASC ' SWITCH, ONE OF THE FOLLOWING' 1
 DFB 0
CMIN03 ASC ' INPUT FILE SPEC' 1
 DFB 0
CMIN04 ASC ' OUTPUT FILE SPEC' 1
 DFB 0
CMIN05 ASC ' INTEGER NUMBER IN BASE ' 1
 DFB 0
DQUOTE EQU '#
DPAKLN EQU $5E
DPADCH EQU NUL
DPADLN EQU 0
DMAXTR EQU $14
DEBQ EQU '&
DTIME EQU 15
DEOL EQU CR
MXPACK EQU DPAKLN
MXFNL EQU $1E
EOF EQU $01
BUFLEN EQU $FF
KERBF1 EQU $1A
KERBF2 EQU $1C
FBSBIT EQU $01
FBEBIT EQU $00
ERRCRI EQU $01
ERRCRF EQU $02
ERRCRD EQU $03
ERRMRC EQU $04
ERRBCH EQU $05
ERRFAE EQU $0A
EMESLN EQU $19
KERRNS EQU $1F
KERDEL EQU $15
KEREMS EQU $19
KERFTS EQU $0B
CSWL EQU $36
CSWH EQU $37
KSWL EQU $38
KSWH EQU $39
ERRPTR EQU $9D5A
BASWS EQU $9D5E
KERPCH EQU $C085
KERPST EQU $C084
PDBUF DS 2*MXPACK-4
PDLEN DFB 0
PTYPE DFB 0
PNUM DFB 0
PLNBUF DS 2*MXPACK
PDTEND DFB 0
PDTIND DFB 0
RSTAT DFB 0
KERRTA DW 0
ESCP DFB 0
FBSIZE DFB FBSBIT
FILMOD DFB 0
USEHDR DFB 0
LECHO DFB 0
IBMMOD DFB 0
VTMOD DFB 0
PARITY DFB 0
DELAY DFB 0
FILWAR DFB 0
DEBUG DFB 0
EBQMOD DFB 0
DATIND DFB 0
CHEBO DFB 0
ESCFLG DFB 0
FILLEN DW 0
FETFL DFB 0
ADDLF DFB 0
DELLF DFB 0
JTADDR DW 0
KWRK01 DFB 0
KWRK02 DFB 0
KERCHR DFB 0
KERMBS DW 0
KERHCS DW 0
KERHKS DW 0
HERRPT DW 0
HBASWS DW 0
DEBCHK DFB 0
DEBINX DFB 0
FLD DFB 0
RETADR DW 0
N DFB 0
NUMTRY DFB 0
OLDTRY DFB 0
MAXTRY DFB 0
STATE DFB 0
LOCAL DFB 0
SIZE DFB 0
CHKSUM DFB 0
RTOT DW 0
STOT DW 0
RCHR DW 0
SCHR DW 0
ROVR DW 0
SOVR DW 0
EOFINP DFB 0
EODIND DFB 0
ERRCOD DFB 0
KEROSP DFB 0
UVAREBQ DFB 0
UVASEBQ DFB 0
SRIND DFB 0
EBQ DFB DEBQ
 DFB DEBQ
PAD DFB DPADLN
 DFB DPADLN
PADCH DFB DPADCH
 DFB DPADCH
EOL DFB DEOL
 DFB DEOL
PSIZ DFB DPAKLN
 DFB DPAKLN
TIME DFB DTIME
 DFB DTIME
QUOTE DFB DQUOTE
 DFB DQUOTE
REBQ EQU EBQ
SEBQ EQU EBQ+1
RPAD EQU PAD
SPAD EQU PAD+1
RPADCH EQU PADCH
SPADCH EQU PADCH+1
REOL EQU EOL
SEOL EQU EOL+1
RPSIZ EQU PSIZ
SPSIZ EQU PSIZ+1
RTIME EQU TIME
STIME EQU TIME+1
RQUOTE EQU QUOTE
SQUOTE EQU QUOTE+1
PRIMFN EQU $AA75
SCNDFN EQU $AA93
FMPARS EQU $B5BB
OPCOD EQU FMPARS
SUBCOD EQU FMPARS+1
RECLH EQU FMPARS+2
RECLL EQU FMPARS+3
CVOL EQU FMPARS+4
CDISK EQU FMPARS+5
CSLOT EQU FMPARS+6
FTYPE EQU FMPARS+7
FNADRL EQU FMPARS+8
FNADRH EQU FMPARS+9
FMRCOD EQU FMPARS+10
FMWADL EQU FMPARS+12
FMWADH EQU FMPARS+13
TSLBFL EQU FMPARS+14
TSLBFH EQU FMPARS+15
DSBUFL EQU FMPARS+16
DSBUFH EQU FMPARS+17
RNUMH EQU FMPARS+2
RNUML EQU FMPARS+3
BYTOFH EQU FMPARS+4
BYTOFL EQU FMPARS+5
RNGLNH EQU FMPARS+7
RNGLNL EQU FMPARS+6
FNCOPN EQU $01
FNCCLO EQU $02
FNCREA EQU $03
FNCWRT EQU $04
FNCPOS EQU $0A
SFNTRN EQU $02
SFNPTR EQU $04
DOSOPN EQU $A3D5
DOSONC EQU $A2A8
DOSCLO EQU $A2EA
DOSDEL EQU $A263
DOSFMN EQU $AB06
LOCENT EQU $B1C9
DOSCMI EQU $AA5F
DSENER EQU $00
DSEBCT EQU $02
DSEBST EQU $03
DSEWPR EQU $04
DSEEOD EQU $05
DSEFNF EQU $06
DSEVMM EQU $07
DSEDIO EQU $08
DSEDFL EQU $09
DSEFLK EQU $0A
KERFCB EQU $1E
MXDB EQU $7F
DSBFCC DFB $00
DSBIND DFB $00
DSBEND DFB $00
DOSFFM DFB $00
DOSFNI DFB $00
DOSFVN DFB $00
FCB1 DS $1F
DOSBUF DS $100
KSTART JSR SETIO1
 JSR SETIO2
 JSR HOME
 LDX #VERSIO
 LDY #<VERSIO
 JSR PRSTR
 JSR PRCRLF
 LDA ERRPTR
 STA HERRPT
 LDA ERRPTR+1
 STA HERRPT+1
 LDA BASWS
 STA HBASWS
 LDA BASWS+1
 STA HBASWS+1
 LDA #NONFTL
 STA ERRPTR
 LDA #<NONFTL
 STA ERRPTR+1
 LDA #NONFTL
 STA BASWS
 LDA #<NONFTL
 STA BASWS+1
 LDA #ON
 STA VTMOD
 LDA #OFF
 STA EBQMOD
 LDA #DMAXTR
 STA MAXTRY
 JSR KERMIT
 JMP DOS
 BRK
KERMIT TSX
 STX KEROSP
 LDA #CMINI
 JSR COMND
 LDA #KERCMD
 STA CMINF1
 LDA #<KERCMD
 STA CMINF1+1
 LDA #KERHLP
 STA CMHPTR
 LDA #<KERHLP
 STA CMHPTR+1
 LDA #CMKEY
 JSR COMND
  JMP KERMT2
 LDA #KERMTB
 SEC
 SBC #$01
 STA JTADDR
 LDA #<KERMTB
 SBC #$00
 STA JTADDR+1
 TXA
 CLC
 ADC JTADDR
 TAX
 LDA JTADDR+1
 ADC #$00
 PHA
 TXA
 PHA
 RTS
KERMTB JMP TELNET
 JMP EXIT
 JMP HELP
 JMP LOG
 JMP EXIT
 JMP RECEVE
 JMP SEND
 JMP SETCOM
 JMP SHOW
 JMP STATUS
KERMT2 LDX #ERMES1
 LDY #<ERMES1
 JSR PRSTR
 JMP KERMIT
KERMT3 LDX #ERMES3
 LDY #<ERMES3
 JSR PRSTR
 JMP KERMIT
KERMT4 LDX #ERMES4
 LDY #<ERMES4
 JSR PRSTR
 JMP KERMIT
KERMT5 LDX #ERMES6
 LDY #<ERMES6
 JSR PRSTR
 JMP KERMIT
KERMT6 LDX #ERMES7
 LDY #<ERMES7
 JSR PRSTR
 JMP KERMIT
KERMT7 LDX #ERMES8
 LDY #<ERMES8
 JSR PRSTR
 JMP KERMIT
KERMT8 LDX #ERMES9
 LDY #<ERMES9
 JSR PRSTR
 JMP KERMIT
TELNET JSR PRCFM
 LDX #INF01A
 LDY #<INF01A
 JSR PRSTR
 LDA ESCP
 JSR PRCHR
 LDX #INF01B
 LDY #<INF01B
 JSR PRSTR
 JSR PRCRLF
CHRLUP JSR TELPRC
 JSR TELCNC
  JMP KERMIT
 JMP CHRLUP
TELPRC JSR TELCP
 CMP #FALSE
 BEQ TELPRR
 JSR TELGPC
TELPR2 TAY
 LDA VTMOD
 CMP #ON
 BNE TELPR3
 LDA ESCFLG
 CMP #ON
 BNE TELP2A
 JMP VT52
TELP2A TYA
 CMP #DEL
 BEQ TELPRR
 CMP #ESC
 BNE TELPR3
 LDA #ON
 STA ESCFLG
 JMP TELPRC
TELPR3 TYA
 ORA #$80
 CMP #$E0
 BMI TELPR4
 AND #$DF
TELPR4 JSR COUT
 JMP TELPRC
TELPRR RTS
TELCNC BIT KBD
 BPL TELCRS
 LDA KBD
 TAX
 BIT KBDSTR
 TXA
 AND #$7F
 CMP ESCP
 BEQ INTCHR
 JSR TELPPC
 TAX
 LDA LECHO
 CMP #ON
 BNE TELCRS
 TXA
 JSR COUT
TELCRS JMP RSKP
INTCHR JSR RDKEY
 STA KERCHR
 AND #$5F
 CMP #'C
 BNE INTCH0
 RTS
INTCH0 CMP #'S
 BNE INTCH1
 JMP STAT01
INTCH1 LDA KERCHR
 AND #$7F
 CMP #'?
 BNE INTCH2
 LDX #INTHLP
 LDY #<INTHLP
 JSR PRSTR
 JMP INTCHR
INTCH2 CMP ESCP
 BNE INTCH3
 JSR TELPPC
 JMP RSKP
INTCH3 JSR BELL
 JMP RSKP
VT52 LDA #OFF
 STA ESCFLG
 TYA
 AND #$7F
 CMP #'A
 BMI VTIG
 CMP #'Y'+1
 BPL VTIG
 CMP #'A
 BNE VT52A
 JSR UPLINE
 RTS
VT52A CMP #'B
 BNE VT52B
 JSR LFEED
 RTS
VT52B CMP #'C
 BNE VT52C
 JSR ADVANC
 RTS
VT52C CMP #'D
 BNE VT52D
 JSR BSP
 RTS
VT52D CMP #'H
 BNE VT52E
 LDA #$00
 STA CH
 STA CV
 JSR VTABZ
 RTS
VT52E CMP #'I
 BNE VT52F
 LDA CV
 CMP #$00
 BEQ VT52E1
 JSR UPLINE
 RTS
VT52E1 JSR VRSCRL
 RTS
VT52F CMP #'J
 BNE VT52G
 JSR CLREOP
 RTS
VT52G CMP #'K
 BNE VT52H
 JSR CLREOL
 RTS
VT52H CMP #'Y
 BNE VTIG
 JSR VTDCA
 RTS
VTIG ORA #$80
 PHA
 LDA #HESC
 JSR PRCHR
 PLA
 CMP #ESC
 BNE VTIG1
 LDA #ON
 STA ESCFLG
 RTS
VTIG1 JSR PRCHR
 RTS
VRSCRL LDA WNDBTM
 PHA
 JSR VTABZ
VRSC1 LDA BASL
 STA BAS2L
 LDA BASH
 STA BAS2H
 LDY WNDWTH
 DEY
 PLA
 SEC
 SBC #$01
 CMP WNDTOP
 BCS VRSC3
 PHA
 JSR VTABZ
VRSC2 LDA (BASL),Y
 STA (BAS2L),Y
 DEY
 BPL VRSC2
 BMI VRSC1
VRSC3 JSR SCRL3
 RTS
VTDCA JSR TELCP
 CMP #FALSE
 BEQ VTDCA
 JSR TELGPC
 AND #$7F
 SEC
 SBC #$20
 CMP #$00
 BPL VTDCA1
 CLC
 ADC #$20
 JMP VTIG
VTDCA1 CMP #$23
 BMI VTDCA2
 CLC
 ADC #$20
 JMP VTIG
VTDCA2 STA HCV
VTDCA3 JSR TELCP
 CMP #FALSE
 BEQ VTDCA3
 JSR TELGPC
 AND #$7F
 SEC
 SBC #$20
 CMP #$00
 BPL VTDCA4
 CLC
 ADC #$20
 JMP VTIG
VTDCA4 CMP #$28
 BMI VTDCA5
 CLC
 ADC #$20
 JMP VTIG
VTDCA5 STA HCH
 LDA HCV
 STA CV
 LDA HCH
 STA CH
 JSR VTAB
 RTS
EXIT LDA HERRPT
 STA ERRPTR
 LDA HERRPT+1
 STA ERRPTR+1
 LDA HBASWS
 STA BASWS
 LDA HBASWS+1
 STA BASWS+1
 LDA #CMCFM
 JSR COMND
  JMP KERMT3
EXIT2 JMP DOS
HELP LDA #CMCFM
 JSR COMND
  JMP KERMT3
HELP2 LDX CMHPTR
 LDY CMHPTR+1
 JSR PRSTR
 JMP KERMIT
LOG JMP KERMIT
RECEVE LDA #ON
 STA USEHDR
 LDA #FCB1
 STA CMINF1
 LDA #<FCB1
 STA CMINF1+1
 LDA #CMIFI
 JSR COMND
  JMP RECEV1
 LDA #OFF
 STA USEHDR
RECEV1 LDA #CMCFM
 JSR COMND
  JMP KERMT3
 JSR RSWT
 JMP KERMIT
RSWT LDA #'R
 STA STATE
 LDA #$00
 STA N
 STA NUMTRY
 STA OLDTRY
 STA EOFINP
 STA ERRCOD
 STA RTOT
 STA RTOT+1
 STA STOT
 STA STOT+1
 STA RCHR
 STA RCHR+1
 STA SCHR
 STA SCHR+1
RSWT1 LDA STATE
 CMP #'D
 BNE RSWT2
 JSR RDAT
 JMP RSWT1
RSWT2 CMP #'F
 BNE RSWT3
 JSR RFIL
 JMP RSWT1
RSWT3 CMP #'R
 BNE RSWT4
 JSR RINI
 JMP RSWT1
RSWT4 CMP #'C
 BNE RSWT5
 LDA #TRUE
 RTS
RSWT5 LDA #FALSE
 RTS
RINI LDA #PDBUF
 STA KERBF1
 LDA #<PDBUF
 STA KERBF1+1
 LDA NUMTRY
 INC NUMTRY
 CMP MAXTRY
 BEQ RINI1
 BCS RINI1A
RINI1 JMP RINI2
RINI1A LDA #'A
 STA STATE
 LDA #ERRCRI
 STA ERRCOD
 LDA #FALSE
 RTS
RINI2 JSR RPAK
 STA RSTAT
 LDA PTYPE
 CMP #'S
 BNE RINI2A
 JMP RINICI
RINI2A LDA RSTAT
 CMP #FALSE
 BEQ RINI2B
 LDA #'A
 STA STATE
 LDA #ERRCRI
 STA ERRCOD
 LDA #FALSE
 RTS
RINI2B LDA N
 STA PNUM
 JSR NAKIT
 LDA #FALSE
 RTS
RINICI LDA PNUM
 STA N
 JSR RPAR
 LDA #'Y
 STA PTYPE
 STA UVAREBQ
 LDA N
 STA PNUM
 LDA UVASEBQ
 CMP #'N
 BEQ RINICN
 CMP #'Y
 BEQ RINIUV1
 CMP #$21
 BMI RINICN
 CMP #$3F
 BMI RINICY
 CMP #$60
 BMI RINICN
 CMP #$7F
 BMI RINICY
RINICN LDA #OFF
 STA EBQMOD
 LDA #$06
 JMP RINIC1
RINIUV1 LDA REBQ
 STA UVAREBQ
RINICY LDA #ON
 STA EBQMOD
 LDA #$07
RINIC1 STA PDLEN
 JSR SPAR
 LDA UVAREBQ
 CMP #'Y
 BNE RINIUV2
 LDA UVASEBQ
 STA UVAREBQ
RINIUV2 JSR SPAK
 LDA NUMTRY
 STA OLDTRY
 LDA #$00
 STA NUMTRY
 JSR INCN
 LDA #'F
 STA STATE
 LDA #TRUE
 RTS
RFIL LDA NUMTRY
 INC NUMTRY
 CMP MAXTRY
 BEQ RFIL1
 BCS RFIL1A
RFIL1 JMP RFIL2
RFIL1A LDA #'A
 STA STATE
 LDA #FALSE
 RTS
RFIL2 JSR RPAK
 STA RSTAT
 LDA PTYPE
 CMP #'S
 BNE RFIL2A
 JMP RFILCI
RFIL2A CMP #'Z
 BNE RFIL2B
 JMP RFILCE
RFIL2B CMP #'F
 BNE RFIL2C
 JMP RFILCF
RFIL2C CMP #'B
 BNE RFIL2D
 JMP RFILCB
RFIL2D LDA RSTAT
 CMP #FALSE
 BEQ RFIL2E
 LDA #'A
 STA STATE
 LDA #ERRCRF
 STA ERRCOD
 LDA #FALSE
 RTS
RFIL2E LDA N
 STA PNUM
 JSR NAKIT
 LDA #FALSE
 RTS
RFILCI LDA OLDTRY
 INC OLDTRY
 CMP MAXTRY
 BEQ RFILI1
 BCS RFILI5
RFILI1 JMP RFILI3
RFILI5 LDA #'A
 STA STATE
 LDA #ERRCRF
 STA ERRCOD
 LDA #FALSE
 RTS
RFILI3 LDA PNUM
 CLC
 ADC #$01
 CMP N
 BEQ RFILI4
 JMP RFILI5
RFILI4 JSR SPAR
 LDA #'Y
 STA PTYPE
 LDA #$06
 STA PDLEN
 JSR SPAK
 LDA #$00
 STA NUMTRY
 LDA #TRUE
 RTS
RFILCE LDA OLDTRY
 INC OLDTRY
 CMP MAXTRY
 BEQ RFILE1
 BCS RFILE5
RFILE1 JMP RFILE3
RFILE5 LDA #'A
 STA STATE
 LDA #ERRCRF
 STA ERRCOD
 LDA #FALSE
 RTS
RFILE3 LDA PNUM
 CLC
 ADC #$01
 CMP N
 BEQ RFILE4
 JMP RFILE5
RFILE4 LDA #'Y
 STA PTYPE
 LDA #$00
 STA PDLEN
 JSR SPAK
 LDA #$00
 STA NUMTRY
 LDA #TRUE
 RTS
RFILCF LDA PNUM
 CMP N
 BNE RFILF1
 JMP RFILF2
RFILF1 LDA #'A
 STA STATE
 LDA #ERRCRF
 STA ERRCOD
 LDA #FALSE
 RTS
RFILF2 JSR GETFIL
 LDA #FNCWRT
 JSR OPENF
 LDA #'Y
 STA PTYPE
 LDA #$00
 STA PDLEN
 JSR SPAK
 LDA NUMTRY
 STA OLDTRY
 LDA #$00
 STA NUMTRY
 JSR INCN
 LDA #'D
 STA STATE
 LDA #TRUE
 RTS
RFILCB LDA PNUM
 CMP N
 BNE RFILB1
 JMP RFILB2
RFILB1 LDA #'A
 STA STATE
 LDA #ERRCRF
 STA ERRCOD
 LDA #FALSE
 RTS
RFILB2 LDA #'Y
 STA PTYPE
 LDA #$00
 STA PDLEN
 JSR SPAK
 LDA #'C
 STA STATE
 LDA #TRUE
 RTS
RDAT LDA NUMTRY
 INC NUMTRY
 CMP MAXTRY
 BEQ RDAT1
 BCS RDAT1A
RDAT1 JMP RDAT2
RDAT1A LDA #'A
 STA STATE
 LDA #ERRCRD
 STA ERRCOD
 LDA #FALSE
 RTS
RDAT2 JSR RPAK
 STA RSTAT
 LDA PTYPE
 CMP #'D
 BNE RDAT2A
 JMP RDATCD
RDAT2A CMP #'F
 BNE RDAT2B
 JMP RDATCF
RDAT2B CMP #'Z
 BNE RDAT2C
 JMP RDATCE
RDAT2C LDA RSTAT
 CMP #FALSE
 BEQ RDAT2D
 LDA #'A
 STA STATE
 LDA #ERRCRD
 STA ERRCOD
 LDA #FALSE
 RTS
RDAT2D LDA N
 STA PNUM
 JSR NAKIT
 LDA #FALSE
 RTS
RDATCD LDA PNUM
 CMP N
 BNE RDATD1
 JMP RDATD7
RDATD1 LDA OLDTRY
 INC OLDTRY
 CMP MAXTRY
 BEQ RDATD2
 BCS RDATD6
RDATD2 JMP RDATD4
RDATD6 LDA #'A
 STA STATE
 LDA #ERRCRD
 STA ERRCOD
 LDA #FALSE
 RTS
RDATD4 LDA PNUM
 CLC
 ADC #$01
 CMP N
 BEQ RDATD5
 JMP RDATD6
RDATD5 JSR SPAR
 LDA #'Y
 STA PTYPE
 LDA #$06
 STA PDLEN
 JSR SPAK
 LDA #$00
 STA NUMTRY
 LDA #TRUE
 RTS
RDATD7 JSR BUFEMP
 LDA #'Y
 STA PTYPE
 LDA N
 STA PNUM
 LDA #$00
 STA PDLEN
 JSR SPAK
 LDA NUMTRY
 STA OLDTRY
 LDA #$00
 STA NUMTRY
 JSR INCN
 LDA #'D
 STA STATE
 LDA #TRUE
 RTS
RDATCF LDA OLDTRY
 INC OLDTRY
 CMP MAXTRY
 BEQ RDATF1
 BCS RDATF5
RDATF1 JMP RDATF3
RDATF5 LDA #'A
 STA STATE
 LDA #ERRCRD
 STA ERRCOD
 LDA #FALSE
 RTS
RDATF3 LDA PNUM
 CLC
 ADC #$01
 CMP N
 BEQ RDATF4
 JMP RDATF5
RDATF4 LDA #'Y
 STA PTYPE
 LDA #$00
 STA PDLEN
 JSR SPAK
 LDA #$00
 STA NUMTRY
 LDA #TRUE
 RTS
RDATCE LDA PNUM
 CMP N
 BNE RDATE1
 JMP RDATE2
RDATE1 LDA #'A
 STA STATE
 LDA #ERRCRD
 STA ERRCOD
 LDA #FALSE
 RTS
RDATE2 LDA #'Y
 STA PTYPE
 LDA N
 STA PNUM
 LDA #$00
 STA PDLEN
 JSR SPAK
 LDA #FCB1
 STA KERFCB
 LDA #<FCB1
 STA KERFCB
 LDA #$00
 JSR CLOSEF
 JSR INCN
 LDA #'F
 STA STATE
 LDA #TRUE
 RTS
SEND LDA #FCB1
 STA CMINF1
 LDA #<FCB1
 STA CMINF1+1
 LDA #CMIFI
 JSR COMND
  JMP KERMT6
 JSR PRCFM
 JSR SSWT
 JMP KERMIT
SSWT LDA #'S
 STA STATE
 LDA #$00
 STA EODIND
 STA N
 STA NUMTRY
 STA OLDTRY
 STA EOFINP
 STA ERRCOD
 STA RTOT
 STA RTOT+1
 STA STOT
 STA STOT+1
 STA RCHR
 STA RCHR+1
 STA SCHR
 STA SCHR+1
 LDA #PDBUF
 STA SADDR
 LDA #<PDBUF
 STA SADDR+1
 LDA #$00
 LDY #$00
CLPBUF STA (SADDR),Y
 INY
 CPY #2*MXPACK-4
 BNE CLPBUF
SSWT1 LDA STATE
 CMP #'D
 BNE SSWT2
 JSR SDAT
 JMP SSWT1
SSWT2 CMP #'F
 BNE SSWT3
 JSR SFIL
 JMP SSWT1
SSWT3 CMP #'Z
 BNE SSWT4
 JSR SEOF
 JMP SSWT1
SSWT4 CMP #'S
 BNE SSWT5
 JSR SINI
 JMP SSWT1
SSWT5 CMP #'B
 BNE SSWT6
 JSR SBRK
 JMP SSWT1
SSWT6 CMP #'C
 BNE SSWT7
 LDA #TRUE
 RTS
SSWT7 LDA #FALSE
 RTS
SDAT LDA NUMTRY
 INC NUMTRY
 CMP MAXTRY
 BEQ SDAT1
 BCS SDAT1A
SDAT1 JMP SDAT1B
SDAT1A LDA #'A
 STA STATE
 LDA #FALSE
 RTS
SDAT1B LDA #'D
 STA PTYPE
 LDA N
 STA PNUM
 LDA SIZE
 STA PDLEN
 JSR SPAK
SDAT2 JSR RPAK
 STA RSTAT
 LDA PTYPE
 CMP #'N
 BNE SDAT2A
 JMP SDATCN
SDAT2A CMP #'Y
 BNE SDAT2B
 JMP SDATCA
SDAT2B LDA RSTAT
 CMP #FALSE
 BEQ SDAT2C
 LDA #'A
 STA STATE
 LDA #FALSE
SDAT2C RTS
SDATCN DEC PNUM
 LDA N
 CMP PNUM
 BNE SDATN1
 JMP SDATA2
SDATN1 LDA #FALSE
 RTS
SDATCA LDA N
 CMP PNUM
 BNE SDATN1
SDATA2 LDA #$00
 STA NUMTRY
 JSR INCN
 JSR BUFILL
 STA SIZE
 LDA EOFINP
 CMP #TRUE
 BEQ SDATRZ
 JMP SDATRD
SDATRZ LDA #'Z
 STA STATE
 LDA #TRUE
 RTS
SDATRD LDA #'D
 STA STATE
 LDA #TRUE
 RTS
SFIL LDA FILMOD
 BEQ SFIL0
 LDA #ON
 STA FETFL
SFIL0 LDA NUMTRY
 INC NUMTRY
 CMP MAXTRY
 BEQ SFIL1
 BCS SFIL1A
SFIL1 JMP SFIL1B
SFIL1A LDA #'A
 STA STATE
 LDA #FALSE
 RTS
SFIL1B LDY #$00
SFIL1C LDA FCB1,Y
 CMP #$00
 BEQ SFIL1D
 STA PDBUF,Y
 INY
 JMP SFIL1C
SFIL1D LDA #'
 ORA #$80
 STA FCB1,Y
SFIL1E DEY
 LDA PDBUF,Y
 CMP #0
 BEQ SFIL1E
 CMP #HSPACE
 BEQ SFIL1E
SFIL1F INY
 STY PDLEN
 LDA #'F
 STA PTYPE
 LDA N
 STA PNUM
 JSR SPAK
SFIL2 JSR RPAK
 STA RSTAT
 LDA PTYPE
 CMP #'N
 BNE SFIL2A
 JMP SFILCN
SFIL2A CMP #'Y
 BNE SFIL2B
 JMP SFILCA
SFIL2B LDA RSTAT
 CMP #FALSE
 BNE SFIL2C
 RTS
SFIL2C LDA #'A
 STA STATE
 LDA #FALSE
 RTS
SFILCN DEC PNUM
 LDA PNUM
 CMP N
 BNE SFILN1
 JMP SFILA2
SFILN1 LDA #FALSE
 RTS
SFILCA LDA N
 CMP PNUM
 BNE SFILN1
SFILA2 LDA #$00
 STA NUMTRY
 JSR INCN
 LDA #FCB1
 STA KERFCB
 LDA #<FCB1
 STA KERFCB+1
 LDA #FNCREA
 JSR OPENF
 JSR BUFILL
 STA SIZE
 LDA #'D
 STA STATE
 LDA #TRUE
 RTS
SEOF LDA NUMTRY
 INC NUMTRY
 CMP MAXTRY
 BEQ SEOF1
 BCS SEOF1A
SEOF1 JMP SEOF1B
SEOF1A LDA #'A
 STA STATE
 LDA #ERRMRC
 STA ERRCOD
 LDA #FALSE
 RTS
SEOF1B LDA #'Z
 STA PTYPE
 LDA N
 STA PNUM
 LDA #$00
 STA PDLEN
 JSR SPAK
SEOF2 JSR RPAK
 STA RSTAT
 LDA PTYPE
 CMP #'N
 BNE SEOF2A
 JMP SEOFCN
SEOF2A CMP #'Y
 BNE SEOF2B
 JMP SEOFCA
SEOF2B LDA RSTAT
 CMP #FALSE
 BEQ SEOF2C
 LDA #'A
 STA STATE
 LDA #FALSE
SEOF2C RTS
SEOFCN DEC PNUM
 LDA N
 CMP PNUM
 BNE SEOFN1
 JMP SEOFA2
SEOFN1 LDA #FALSE
 RTS
SEOFCA LDA N
 CMP PNUM
 BNE SEOFN1
SEOFA2 LDA #$00
 STA NUMTRY
 JSR INCN
 JSR GETNFL
 CMP #EOF
 BEQ SEOFRB
 JMP SEOFRF
SEOFRB LDA #'B
 STA STATE
 LDA #TRUE
 RTS
SEOFRF LDA #'F
 STA STATE
 LDA #TRUE
 RTS
SINI LDA #PDBUF
 STA KERBF1
 LDA #<PDBUF
 STA KERBF1+1
 LDA REBQ
 STA UVAREBQ
 JSR SPAR
 LDA NUMTRY
 CMP MAXTRY
 BEQ SINI1
 BCS SINI1A
SINI1 JMP SINI1B
SINI1A LDA #'A
 STA STATE
 LDA #ERRMRC
 STA ERRCOD
 LDA #$00
 RTS
SINI1B INC NUMTRY
 LDA #'S
 STA PTYPE
 LDA EBQMOD
 CMP #ON
 BEQ SINI1C
 LDA #$06
 JMP SINI1D
SINI1C LDA #$07
SINI1D STA PDLEN
 LDA N
 STA PNUM
 JSR SPAK
 JSR RPAK
 STA RSTAT
SINICS LDA PTYPE
 CMP #'Y
 BNE SINIC1
 JMP SINICY
SINIC1 CMP #'N
 BNE SINIC2
 JMP SINICF
SINIC2 LDA RSTAT
 CMP #FALSE
 BNE SINIC3
 JMP SINICF
SINIC3 LDA #'A
 STA STATE
SINICF RTS
SINICY LDY #$00
 LDA N
 CMP PNUM
 BEQ SINIY1
 LDA #FALSE
 RTS
SINIY2 LDA SEBQ
 STA UVASEBQ
 BNE SINIY3
SINIY1 JSR RPAR
 LDA UVASEBQ
 CMP #'Y
 BEQ SINIY2
 LDA #OFF
 STA EBQMOD
SINIY3 LDA #'F
 STA STATE
 LDA #$00
 STA NUMTRY
 JSR INCN
 LDA #TRUE
 RTS
SBRK LDA NUMTRY
 INC NUMTRY
 CMP MAXTRY
 BEQ SBRK1
 BCS SBRK1A
SBRK1 JMP SBRK1B
SBRK1A LDA #'A
 STA STATE
 LDA #ERRMRC
 STA ERRCOD
 LDA #FALSE
 RTS
SBRK1B LDA #'B
 STA PTYPE
 LDA N
 STA PNUM
 LDA #$00
 STA PDLEN
 JSR SPAK
SBRK2 JSR RPAK
 STA RSTAT
 LDA PTYPE
 CMP #'N
 BNE SBRK2A
 JMP SBRKCN
SBRK2A CMP #'Y
 BNE SBRK2B
 JMP SBRKCA
SBRK2B LDA RSTAT
 CMP #FALSE
 BEQ SBRK2C
 LDA #'A
 STA STATE
 LDA #FALSE
SBRK2C RTS
SBRKCN DEC PNUM
 LDA N
 CMP PNUM
 BNE SBRKN1
 JMP SBRKA2
SBRKN1 LDA #FALSE
 RTS
SBRKCA LDA N
 CMP PNUM
 BNE SBRKN1
SBRKA2 LDA #$00
 STA NUMTRY
 JSR INCN
 LDA #'C
 STA STATE
 LDA #TRUE
 RTS
SETCOM LDA #SETCMD
 STA CMINF1
 LDA #<SETCMD
 STA CMINF1+1
 LDA #CMKEY
 JSR COMND
  JMP KERMT2
 LDA #SETCMB
 SEC
 SBC #$01
 STA JTADDR
 LDA #<SETCMB
 SBC #$00
 STA JTADDR+1
 TXA
 CLC
 ADC JTADDR
 TAX
 LDA JTADDR+1
 ADC #$00
 PHA
 TXA
 PHA
 RTS
SETCMB JMP STESC
 JMP STIBM
 JMP STLE
 JMP STRC
 JMP STSN
 JMP STVT
 JMP STFW
 JMP STEB
 JMP STDB
 JMP STMOD
 JMP STFBS
STESC LDX #$10
 LDA #CMNUM
 JSR COMND
  JMP KERMT4
 LDA #CMCFM
 JSR COMND
  JMP KERMT3
 LDA CMINTG+1
 CMP #$00
 BEQ STESC1
 JMP KERMT4
STESC1 LDA CMINTG
 CMP #$7F
 BMI STESC2
 JMP KERMT4
STESC2 STA ESCP
 JMP KERMIT
STIBM JSR PRSON
  JMP KERMT2
 STX IBMMOD
 LDA #CMCFM
 JSR COMND
  JMP KERMT3
 JMP KERMIT
STLE JSR PRSON
  JMP KERMT2
 STX LECHO
 LDA #CMCFM
 JSR COMND
  JMP KERMT3
 JMP KERMIT
STRC LDA #$00
 STA SRIND
 LDA #STSCMD
 STA CMINF1
 LDA #<STSCMD
 STA CMINF1+1
 LDA #CMKEY
 JSR COMND
  JMP KERMT2
 LDA #STCCT
 SEC
 SBC #$01
 STA JTADDR
 LDA #<STCCT
 SBC #$00
 STA JTADDR+1
 TXA
 CLC
 ADC JTADDR
 TAX
 LDA JTADDR+1
 ADC #$00
 PHA
 TXA
 PHA
 RTS
STSN LDA #$01
 STA SRIND
 LDA #STSCMD
 STA CMINF1
 LDA #<STSCMD
 STA CMINF1+1
 LDA #CMKEY
 JSR COMND
  JMP KERMT2
 LDA #STCCT
 SEC
 SBC #$01
 STA JTADDR
 LDA #<STCCT
 SBC #$00
 STA JTADDR+1
 TXA
 CLC
 ADC JTADDR
 TAX
 LDA JTADDR+1
 ADC #$00
 PHA
 TXA
 PHA
 RTS
STCCT JMP STPDC
 JMP STPAD
 JMP STEBQ
 JMP STEOL
 JMP STPL
 JMP STQC
 JMP STTIM
STVT JSR PRSON
  JMP KERMT2
 STX VTMOD
 LDA #CMCFM
 JSR COMND
  JMP KERMT3
 JMP KERMIT
STFW JSR PRSON
  JMP KERMT2
 STX FILWAR
 LDA #CMCFM
 JSR COMND
  JMP KERMT3
 JMP KERMIT
STEB JSR PRSON
  JMP KERMT2
 STX EBQMOD
 LDA #CMCFM
 JSR COMND
  JMP KERMT3
 JMP KERMIT
STDB JSR PRSON
  JMP KERMT2
 STX DEBUG
 LDA #CMCFM
 JSR COMND
  JMP KERMT3
 JMP KERMIT
STEBQ LDX #$10
 LDA #CMNUM
 JSR COMND
  JMP KERMT4
 LDA CMINTG+1
 CMP #$00
 BEQ STEB1
 JMP KERMT4
STEB1 LDA CMINTG
 CMP #$7F
 BMI STEB2
 JMP KERMT4
STEB2 CMP #$21
 BMI STEB4
 CMP #$3F
 BMI STEB3
 CMP #$60
 BMI STEB4
STEB3 LDX SRIND
 STA EBQ,X
 JMP KERMIT
STEB4 LDX #ERMES5
 LDY #<ERMES5
 JSR PRSTR
 JSR PRCFM
 JMP KERMIT
STEOL LDX #$10
 LDA #CMNUM
 JSR COMND
  JMP KERMT4
 LDA CMINTG+1
 CMP #$00
 BEQ STEO1
 JMP KERMT4
STEO1 LDA CMINTG
 CMP #$7F
 BMI STEO2
 JMP KERMT4
STEO2 LDX SRIND
 STA EOL,X
 JSR PRCFM
 JMP KERMIT
STPAD LDX #$10
 LDA #CMNUM
 JSR COMND
  JMP KERMT4
 LDA CMINTG+1
 CMP #$00
 BEQ STPD1
 JMP KERMT4
STPD1 LDA CMINTG
 CMP #$7F
 BMI STPD2
 JMP KERMT4
STPD2 LDX SRIND
 STA PAD,X
 JSR PRCFM
 JMP KERMIT
STPDC LDX #$10
 LDA #CMNUM
 JSR COMND
  JMP KERMT4
 LDA CMINTG+1
 CMP #$00
 BEQ STPC1
 JMP KERMT4
STPC1 LDA CMINTG
 CMP #$7F
 BMI STPC2
 JMP KERMT4
STPC2 LDX SRIND
 STA PADCH,X
 JSR PRCFM
 JMP KERMIT
STPL LDX #$10
 LDA #CMNUM
 JSR COMND
  JMP KERMT4
 LDA CMINTG+1
 CMP #$00
 BEQ STPL1
 JMP KERMT4
STPL1 LDA CMINTG
 CMP #MXPACK
 BMI STPL2
 JMP KERMT4
STPL2 LDX SRIND
 STA PSIZ,X
 JSR PRCFM
 JMP KERMIT
STQC LDX #$10
 LDA #CMNUM
 JSR COMND
  JMP KERMT4
 LDA CMINTG+1
 CMP #$00
 BEQ STQC1
 JMP KERMT4
STQC1 LDA CMINTG
 CMP #$7F
 BMI STQC2
 JMP KERMT4
STQC2 LDX SRIND
 STA QUOTE,X
 JSR PRCFM
 JMP KERMIT
STTIM LDX #$10
 LDA #CMNUM
 JSR COMND
  JMP KERMT4
 LDA CMINTG+1
 CMP #$00
 BEQ STTM1
 JMP KERMT4
STTM1 LDA CMINTG
 CMP #$7F
 BMI STTM2
 JMP KERMT4
STTM2 LDX SRIND
 STA TIME,X
 JSR PRCFM
 JMP KERMIT
STMOD LDA #FTCMD
 STA CMINF1
 LDA #<FTCMD
 STA CMINF1+1
 LDA #CMKEY
 JSR COMND
  JMP KERMT2
 TXA
 BEQ UVAST2
 CMP #4
 BNE UVAST3
 LDA #FBEBIT
 STA FBSIZE
 LDA #1
UVAST3 CMP #5
 BNE UVAST1
 LDX #0
UVAST2 LDA #FBSBIT
 STA FBSIZE
UVAST1 STX FILMOD
 LDA #CMCFM
 JSR COMND
  JMP KERMT3
 JMP KERMIT
STFBS LDA #FBSKEY
 STA CMINF1
 LDA #<FBSKEY
 STA CMINF1+1
 LDA #CMKEY
 JSR COMND
  JMP KERMT2
 STX FBSIZE
 LDA #CMCFM
 JSR COMND
  JMP KERMT3
 JMP KERMIT
SHOW JSR PRCRLF
 JSR SHALL
 JMP KERMIT
 JSR PRCFM
 JSR SHESC
 JMP KERMIT
 JSR PRCFM
 JSR SHIBM
 JMP KERMIT
 JSR PRCFM
 JSR SHLE
 JMP KERMIT
 NOP
 NOP
 NOP
 JSR SHRC
 JMP KERMIT
 NOP
 NOP
 NOP
 JSR SHSN
 JMP KERMIT
 JSR PRCFM
 JSR SHVT
 JMP KERMIT
 JSR PRCFM
 JSR SHFW
 JMP KERMIT
 JSR PRCFM
 JSR SHEB
 JMP KERMIT
 JSR PRCFM
 JSR SHDB
 JMP KERMIT
 JSR PRCFM
 JSR SHMOD
 JMP KERMIT
 JSR PRCFM
 JSR SHFBS
 JMP KERMIT
SHALL JSR SHDB
 JSR SHVT
 JSR SHLE
 JSR SHEB
 JSR SHFW
 JSR SHESC
 JSR SHMOD
 JSR SHFBS
 JSR SHRCAL
 JSR SHSNAL
 RTS
SHDB LDX #SHIN00
 LDY #<SHIN00
 JSR PRSTR
 LDA DEBUG
 JMP PRON
SHVT LDX #SHIN01
 LDY #<SHIN01
 JSR PRSTR
 LDA VTMOD
 JMP PRON
SHIBM LDX #SHIN02
 LDY #<SHIN02
 JSR PRSTR
 LDA IBMMOD
 JMP PRON
SHLE LDX #SHIN03
 LDY #<SHIN03
 JSR PRSTR
 LDA LECHO
 JMP PRON
SHEB LDX #SHIN04
 LDY #<SHIN04
 JSR PRSTR
 LDA EBQMOD
 JMP PRON
SHFW LDX #SHIN05
 LDY #<SHIN05
 JSR PRSTR
 LDA FILWAR
 JMP PRON
SHESC LDX #SHIN06
 LDY #<SHIN06
 JSR PRSTR
 LDA ESCP
 JSR PRCHR
 JSR PRCRLF
 RTS
SHSN LDA #$01
 STA SRIND
 LDA #STSCMD
 STA CMINF1
 LDA #<STSCMD
 STA CMINF1+1
 LDA #CMKEY
 JSR COMND
  JMP KERMT2
 STX KWRK01
 JSR PRCFM
 LDA KWRK01
 CLC
 ADC KWRK01
 STA KWRK01
 LDA #SHCMB
 SEC
 SBC #$01
 STA JTADDR
 LDA #<SHCMB
 SBC #$00
 STA JTADDR+1
 LDA KWRK01
 CLC
 ADC JTADDR
 TAX
 LDA JTADDR+1
 ADC #$00
 PHA
 TXA
 PHA
 RTS
SHRC LDA #$00
 STA SRIND
 LDA #STSCMD
 STA CMINF1
 LDA #<STSCMD
 STA CMINF1+1
 LDA #CMKEY
 JSR COMND
  JMP KERMT2
 STX KWRK01
 JSR PRCFM
 LDA KWRK01
 CLC
 ADC KWRK01
 STA KWRK01
 LDA #SHCMB
 SEC
 SBC #$01
 STA JTADDR
 LDA #<SHCMB
 SBC #$00
 STA JTADDR+1
 LDA KWRK01
 CLC
 ADC JTADDR
 TAX
 LDA JTADDR+1
 ADC #$00
 PHA
 TXA
 PHA
 RTS
SHCMB JSR SHPDC
 JMP KERMIT
 JSR SHPAD
 JMP KERMIT
 JSR SHEBQ
 JMP KERMIT
 JSR SHEOL
 JMP KERMIT
 JSR SHPL
 JMP KERMIT
 JSR SHQC
 JMP KERMIT
 JSR SHTIM
 JMP KERMIT
SHPDC LDX #SHIN11
 LDY #<SHIN11
 JSR PRSTR
 LDX SRIND
 LDA PADCH,X
 JSR PRCHR
 JSR PRCRLF
 RTS
SHPAD LDX #SHIN12
 LDY #<SHIN12
 JSR PRSTR
 LDX SRIND
 LDA PAD,X
 JSR PRBYTE
 JSR PRCRLF
 RTS
SHEBQ LDX #SHIN08
 LDY #<SHIN08
 JSR PRSTR
 LDX SRIND
 LDA EBQ,X
 JSR PRCHR
 JSR PRCRLF
 RTS
SHEOL LDX #SHIN09
 LDY #<SHIN09
 JSR PRSTR
 LDX SRIND
 LDA EOL,X
 JSR PRCHR
 JSR PRCRLF
 RTS
SHPL LDX #SHIN10
 LDY #<SHIN10
 JSR PRSTR
 LDX SRIND
 LDA PSIZ,X
 JSR PRBYTE
 JSR PRCRLF
 RTS
SHQC LDX #SHIN13
 LDY #<SHIN13
 JSR PRSTR
 LDX SRIND
 LDA QUOTE,X
 JSR PRCHR
 JSR PRCRLF
 RTS
SHTIM LDX #SHIN14
 LDY #<SHIN14
 JSR PRSTR
 LDX SRIND
 LDA TIME,X
 JSR PRBYTE
 JSR PRCRLF
 RTS
SHSNAL LDA #$01
 STA SRIND
 LDX #SHIN07
 LDY #<SHIN07
 JSR PRSTR
 JSR PRCRLF
 JSR SHPDC
 JSR SHPAD
 JSR SHEBQ
 JSR SHEOL
 JSR SHPL
 JSR SHQC
 JSR SHTIM
 RTS
SHRCAL LDA #$00
 STA SRIND
 LDX #SHIN15
 LDY #<SHIN15
 JSR PRSTR
 JSR PRCRLF
 JSR SHPDC
 JSR SHPAD
 JSR SHEBQ
 JSR SHEOL
 JSR SHPL
 JSR SHQC
 JSR SHTIM
 RTS
SHMOD LDX #SHIN16
 LDY #<SHIN16
 JSR PRSTR
 LDA FILMOD
 CMP #$04
 BMI SHMOD1
 LDA #$03
SHMOD1 TAX
 LDA #KERFTP
 STA KERMBS
 LDA #<KERFTP
 STA KERMBS+1
 LDA #KERFTS
 PHA
 TXA
 PHA
 JSR GENMAD
 JSR PRSTR
 JSR PRCRLF
 RTS
SHFBS LDX #SHIN17
 LDY #<SHIN17
 JSR PRSTR
 LDA FBSIZE
 BEQ SHFBSE
 LDX #SHSBIT
 LDY #<SHSBIT
 JSR PRSTR
 JSR PRCRLF
 RTS
SHFBSE LDX #SHEBIT
 LDY #<SHEBIT
 JSR PRSTR
 JSR PRCRLF
 RTS
STATUS JSR PRCFM
STAT01 LDX #STIN00
 LDY #<STIN00
 JSR PRSTR
 LDA SCHR
 TAX
 LDA SCHR+1
 JSR PRNTAX
 JSR PRCRLF
 LDX #STIN01
 LDY #<STIN01
 JSR PRSTR
 LDA RCHR
 TAX
 LDA RCHR+1
 JSR PRNTAX
 JSR PRCRLF
 LDX #STIN02
 LDY #<STIN02
 JSR PRSTR
 LDA STOT
 TAX
 LDA STOT+1
 JSR PRNTAX
 JSR PRCRLF
 LDX #STIN03
 LDY #<STIN03
 JSR PRSTR
 LDA RTOT
 TAX
 LDA RTOT+1
 JSR PRNTAX
 JSR PRCRLF
 JSR PRCRLF
 LDX #STIN04
 LDY #<STIN04
 JSR PRSTR
 SEC
 LDA STOT
 SBC SCHR
 TAX
 LDA STOT+1
 SBC SCHR+1
 JSR PRNTAX
 JSR PRCRLF
 LDX #STIN05
 LDY #<STIN05
 JSR PRSTR
 SEC
 LDA RTOT
 SBC RCHR
 TAX
 LDA RTOT+1
 SBC RCHR+1
 JSR PRNTAX
 JSR PRCRLF
 JSR PRCRLF
 LDX #STIN06
 LDY #<STIN06
 JSR PRSTR
 JSR PRCRLF
 LDA #KEREMS
 PHA
 LDA ERRCOD
 BMI STAT02
 PHA
 LDA #ERMS0A
 STA KERMBS
 LDA #<ERMS0A
 STA KERMBS+1
 JMP STATLE
STAT02 AND #$7F
 BEQ STAT03
 SEC
 SBC #$01
STAT03 PHA
 LDA #DSKERS
 STA KERMBS
 LDA #<DSKERS
 STA KERMBS+1
STATLE JSR GENMAD
 JSR PRSTR
 JSR PRCRLF
 JSR PRCRLF
 JMP KERMIT
SPAK LDX #SNIN01
 LDY #<SNIN01
 JSR PRSTR
 LDA PNUM
 JSR PRBYTE
 JSR PRCRLF
 LDA DEBUG
 CMP #ON
 BNE SPAKND
 LDA #$00
 JSR DEBG
SPAKND LDA SPADCH
 LDX #$00
SPAKPD CPX SPAD
 BCS SPAKST
 INX
 JSR TELPPC
 JMP SPAKPD
SPAKST LDA #SOH
 JSR TELPPC
 LDA PDLEN
 CLC
 ADC #$03
 PHA
 CLC
 ADC #SP
 STA CHKSUM
 JSR TELPPC
 PLA
 CLC
 ADC STOT
 STA STOT
 LDA STOT+1
 ADC #$00
 STA STOT+1
 LDA PNUM
 CLC
 ADC #SP
 PHA
 CLC
 ADC CHKSUM
 STA CHKSUM
 PLA
 JSR TELPPC
 LDA PTYPE
 AND #$7F
 PHA
 CLC
 ADC CHKSUM
 STA CHKSUM
 PLA
 JSR TELPPC
 LDY #$00
 STY DATIND
SPAKLP LDY DATIND
 CPY PDLEN
 BMI SPAKDC
 JMP SPAKCH
SPAKDC LDA (KERBF1),Y
 AND #$7F
 CLC
 ADC CHKSUM
 STA CHKSUM
 LDA (KERBF1),Y
 JSR TELPPC
 INC DATIND
 JMP SPAKLP
SPAKCH LDA CHKSUM
 AND #$C0
 LSR A
 LSR A
 LSR A
 LSR A
 LSR A
 LSR A
 CLC
 ADC CHKSUM
 AND #$3F
 CLC
 ADC #SP
 JSR TELPPC
 LDA SEOL
 JSR TELPPC
 LDA DEBUG
 CMP #ON
 BNE SPAKCR
 LDA #$01
 JSR DEBG
SPAKCR RTS
RPAK JSR GOBBLE
  JMP RPKFLS
 LDX #RCIN01
 LDY #<RCIN01
 JSR PRSTR
 LDA PNUM
 JSR PRBYTE
 JSR PRCRLF
 LDA DEBUG
 CMP #ON
 BNE RPAKND
 LDA #$02
 JSR DEBG
RPAKND LDA #$00
 STA CHKSUM
 STA DATIND
 STA KERCHR
RPAKFS JSR GETPLC
  JMP RPKFLS
 STA KERCHR
 AND #$7F
 CMP #SOH
 BNE RPAKFS
 LDA #$01
 STA FLD
RPKLP1 LDA FLD
 CMP #$06
 BMI RPKLP2
 JMP RPKCHK
RPKLP2 CMP #$05
 BNE RPKIF1
 LDA DATIND
 CMP #$00
 BNE RPKIF1
 JMP RPKIF2
RPKIF1 JSR GETPLC
  JMP RPKFLS
 STA KERCHR
 AND #$7F
 CMP #SOH
 BNE RPKIF2
 LDA #$00
 STA FLD
RPKIF2 LDA FLD
 CMP #$04
 BPL RPKSWT
 LDA KERCHR
 CLC
 ADC CHKSUM
 STA CHKSUM
RPKSWT LDA FLD
 CMP #$00
 BNE RPKC1
 LDA #$00
 STA CHKSUM
 JMP RPKEF
RPKC1 CMP #$01
 BNE RPKC2
 LDA KERCHR
 SEC
 SBC #SP
 SEC
 SBC #$03
 STA PDLEN
 JMP RPKEF
RPKC2 CMP #$02
 BNE RPKC3
 LDA KERCHR
 SEC
 SBC #SP
 STA PNUM
 JMP RPKEF
RPKC3 CMP #$03
 BNE RPKC4
 LDA KERCHR
 STA PTYPE
 JMP RPKEF
RPKC4 CMP #$04
 BNE RPKC5
 LDY #$00
 STY DATIND
RPKCHL LDY DATIND
 CPY PDLEN
 BMI RPKIF3
 JMP RPKEF
RPKIF3 CPY #$00
 BEQ RPKACC
 JSR GETPLC
  JMP RPKFLS
 STA KERCHR
 AND #$7F
 CMP #SOH
 BNE RPKACC
 LDA #$FF
 STA FLD
 JMP RPKEF
RPKACC LDA KERCHR
 CLC
 ADC CHKSUM
 STA CHKSUM
 LDA KERCHR
 LDY DATIND
 STA (KERBF1),Y
 INC DATIND
 JMP RPKCHL
RPKC5 CMP #$05
 BEQ RPKC51
 JMP RPKPE
RPKC51 LDA CHKSUM
 AND #$C0
 LSR A
 LSR A
 LSR A
 LSR A
 LSR A
 LSR A
 CLC
 ADC CHKSUM
 AND #$3F
 STA CHKSUM
RPKEF INC FLD
 JMP RPKLP1
RPKCHK LDA KERCHR
 SEC
 SBC #SP
 CMP CHKSUM
 BEQ RPKRET
 LDA #$06
 STA ERRCOD
 LDX #ERMS15
 LDY #<ERMS15
 JSR PRSTR
 LDA KERCHR
 JSR PRBYTE
 LDA #SP
 JSR COUT
 LDA CHKSUM
 JSR PRBYTE
RPKFLS LDA DEBUG
 CMP #ON
 BNE RPKFND
 LDA #$03
 JSR DEBG
RPKFND LDA PDLEN
 CLC
 ADC RTOT
 STA RTOT
 LDA RTOT+1
 ADC #$00
 STA RTOT+1
 LDA #FALSE
 RTS
RPKRET LDA DEBUG
 CMP #ON
 BNE RPKRND
 LDA #$04
 JSR DEBG
RPKRND LDA PDLEN
 CLC
 ADC RTOT
 STA RTOT
 LDA RTOT+1
 ADC #$00
 STA RTOT+1
 LDA #TRUE
 RTS
RPKPE LDX #ERMS16
 LDY #<ERMS16
 JSR PRSTR
 LDA #$07
 STA ERRCOD
 JMP RPKFLS
DEBG TAX
 STA DEBINX
 LDA STATE
 CMP #$00
 BEQ DEBGRF
 CMP #'C
 BEQ DEBGRF
 LDA #KERRTS
 STA KERMBS
 LDA #<KERRTS
 STA KERMBS+1
 LDA #KERRNS
 PHA
 TXA
 PHA
 JSR GENMAD
 JSR PRSTR
 LDA PTYPE
 PHA
 ORA #$80
 JSR COUT
 JSR PRCRLF
 PLA
 STA DEBCHK
 LDA DEBINX
 BNE DEBG1
 JSR DEBPRD
DEBG1 CMP #$04
 BNE DEBGRT
 JSR DEBPRD
DEBGRT LDA #TRUE
 RTS
DEBGRF LDA #FALSE
 RTS
DEBPRD JSR PRCRLF
 LDX #DEBMS1
 LDY #<DEBMS1
 JSR PRSTR
 JSR PRCRLF
 LDX #DEBMS2
 LDY #<DEBMS2
 JSR PRSTR
 LDA PNUM
 PHA
 JSR PRBYTE
 JSR PRCRLF
 PLA
 CLC
 ADC #$20
 CLC
 ADC DEBCHK
 STA DEBCHK
 LDX #DEBMS3
 LDY #<DEBMS3
 JSR PRSTR
 LDA PDLEN
 PHA
 JSR PRBYTE
 JSR PRCRLF
 PLA
 CLC
 ADC #$20
 CLC
 ADC #$03
 CLC
 ADC DEBCHK
 STA DEBCHK
 LDY #$FF
DEBPRC INY
 CPY PDLEN
 BPL DEBDON
 LDA (KERBF1),Y
 CLC
 ADC DEBCHK
 STA DEBCHK
 LDA (KERBF1),Y
 JSR PRCHR
 LDX #$01
 JSR PRBL2
 JMP DEBPRC
DEBDON JSR PRCRLF
 LDX #DEBMS4
 LDY #<DEBMS4
 JSR PRSTR
 LDA DEBCHK
 AND #$C0
 LSR A
 LSR A
 LSR A
 LSR A
 LSR A
 LSR A
 CLC
 ADC DEBCHK
 AND #$3F
 JSR PRBYTE
 JSR PRCRLF
 JSR PRCRLF
 RTS
OPENF PHA
 CMP #FNCWRT
 BEQ OPENFW
 LDA #$01
 STA DOSCMI
 JMP OPNMFS
OPENFW LDA #ON
 STA DOSFFM
 LDA FILWAR
 CMP #ON
 BNE OPNNLU
OPNLU JSR LOOKUP
  JMP OPNNLU
 LDA DOSFFM
 CMP #ON
 BNE OPNALT
 LDX #ERMS1A
 LDY #<ERMS1A
 JSR PRSTR
OPNALT JSR ALTERF
 JMP OPNLU
OPNNLU LDA #$00
 STA DOSCMI
OPNMFS LDY #$00
OPNMFN LDA FCB1,Y
 ORA #$80
 CMP #$80
 BNE OPNMFC
 LDA #HSPACE
OPNMFC STA PRIMFN,Y
 INY
 CPY #MXFNL+1
 BPL OPNFIL
 JMP OPNMFN
OPNFIL LDA FILMOD
 JSR DOSOPN
 PLA
 CMP #FNCWRT
 BEQ OPNSIW
 LDA #MXDB
 STA DSBIND
 LDA #MXDB-1
 STA DSBEND
 LDA #TRUE
 RTS
OPNSIW LDA #$00
 STA DSBIND
 LDA #MXDB
 STA DSBEND
 LDA #TRUE
 RTS
LOOKUP LDA #FCB1
 STA FNADRL
 LDA #<FCB1
 STA FNADRH
 JSR LOCENT
 BCS LOCFNF
 LDA #ERRFAE
 STA ERRCOD
 JMP RSKP
LOCFNF RTS
ALTERF LDA DOSFFM
 CMP #ON
 BEQ ALTFM
 JMP ALTSM
ALTFM LDA #OFF
 STA DOSFFM
 LDY #MXFNL
ALTGNC LDA FCB1,Y
 CMP #HSPACE
 BNE ALTCO
 DEY
 BPL ALTGNC
 LDY #$00
ALTCO STY DOSFNI
 INY
 INY
 CPY #MXFNL
 BPL ALTNG
 LDA #'.
 ORA #$80
 LDY DOSFNI
 INY
 STA FCB1,Y
 LDA #$00
 STA DOSFVN
 INY
 STY DOSFNI
 JSR ALTSTV
 RTS
ALTSM LDX DOSFVN
 INX
 STX DOSFVN
 BEQ ALTNG
 TXA
 JSR ALTSTV
 RTS
ALTNG LDA #$09
 STA ERRCOD
 LDX KEROSP
 TXS
 JMP KERMIT
ALTSTV LDY DOSFNI
 PHA
 LSR A
 LSR A
 LSR A
 LSR A
 JSR ALTSTF
 PLA
 AND #$0F
 INY
 JSR ALTSTF
 RTS
ALTSTF ORA #$B0
 CMP #$BA
 BCC ALTDEP
 ADC #$06
ALTDEP STA FCB1,Y
 RTS
CLOSEF CMP #$00
 BNE CLONLB
 JSR CLOWLB
CLONLB LDY #$00
CLOMFN LDA FCB1,Y
 STA PRIMFN,Y
 INY
 CPY #MXFNL+1
 BPL CLOFIL
 JMP CLOMFN
CLOFIL LDA FILMOD
 JSR DOSCLO
 LDA #TRUE
 RTS
CLOWLB LDA DSBIND
 BEQ CLOWLR
 LDA #FNCWRT
 STA OPCOD
 LDA #$00
 STA RNGLNH
 DEC DSBIND
 LDA DSBIND
 STA RNGLNL
 LDA #SFNTRN
 STA SUBCOD
 LDA #DOSBUF
 STA FNADRL
 LDA #<DOSBUF
 STA FNADRH
 JSR DOSFMN
 CMP #DSENER
 BEQ CLOWLR
 ORA #$80
 STA ERRCOD
CLOWLR RTS
BUFILL LDA #$00
 STA DATIND
BUFIL1 JSR FGETC
  JMP BFFCHK
 STA KERCHR
 LDA FILMOD
 BEQ BUFCET
 SEC
 LDA FILLEN
 SBC #$01
 STA FILLEN
 LDA FILLEN+1
 SBC #$00
 STA FILLEN+1
 CMP #$FF
 BEQ BUFCFL
 JMP BUFCEB
BUFCFL LDA FILLEN
 CMP #$FF
 BNE BUFCEB
 LDX DSBEND
 STX DSBIND
 LDA #ON
 STA EODIND
 JMP BFFRET
BUFCET LDA KERCHR
 AND #$7F
 BNE BUFCEB
 LDX DSBEND
 STX DSBIND
 JMP BFFCHK
BUFCEB LDA EBQMOD
 CMP #ON
 BEQ BUFIL2
 JMP BFFQC
BUFIL2 LDA KERCHR
 AND #$80
 BEQ BFFQC
 LDA UVASEBQ
 LDY DATIND
 STA (KERBF1),Y
 INY
 STY DATIND
 LDA KERCHR
 AND #$7F
 STA KERCHR
BFFQC LDA KERCHR
 AND #$7F
BFFQC0 CMP #SP
 BPL BFFQC1
 LDX FILMOD
 BNE BFFCTL
 CMP #CR
 BNE BFFCTL
 LDX #ON
 STX ADDLF
 JMP BFFCTL
BFFQC1 CMP #DEL
 BNE BFFQC2
 JMP BFFCTL
BFFQC2 CMP SQUOTE
 BNE BFFQC3
 JMP BFFSTQ
BFFQC3 CMP UVASEBQ
 BNE BFFSTF
 JMP BFFSTQ
BFFCTL LDA KERCHR
 EOR #$40
 STA KERCHR
BFFSTQ LDA SQUOTE
 LDY DATIND
 STA (KERBF1),Y
 INY
 STY DATIND
BFFSTF INC SCHR
 BNE BFFSDC
 INC SCHR+1
BFFSDC LDA KERCHR
 LDY DATIND
 STA (KERBF1),Y
 INY
 STY DATIND
 TYA
 CLC
 ADC #$06
 CMP SPSIZ
 BPL BFFRET
 JMP BUFIL1
BFFRET LDA DATIND
 RTS
BFFCHK LDA DATIND
 CMP #$00
 BNE BFFNE
 TAY
 LDA #TRUE
 STA EOFINP
 TYA
BFFNE RTS
BUFEMP LDA #$00
 STA DATIND
BFETOL LDA DATIND
 CMP PDLEN
 BMI BFEMOR
 RTS
BFEMOR LDA #FALSE
 STA CHEBO
 LDY DATIND
 LDA (KERBF1),Y
 STA KERCHR
 CMP UVAREBQ
 BNE BFEQC
 LDA EBQMOD
 CMP #ON
 BNE BFEOUT
 LDA #TRUE
 STA CHEBO
 INC DATIND
 LDY DATIND
 LDA (KERBF1),Y
 STA KERCHR
BFEQC CMP RQUOTE
 BNE BFECEB
 INC DATIND
 LDY DATIND
 LDA (KERBF1),Y
 STA KERCHR
 AND #$7F
 CMP RQUOTE
 BEQ BFECEB
 CMP UVAREBQ
 BEQ BFECEB
 LDA KERCHR
 EOR #$40
 STA KERCHR
BFECEB LDA CHEBO
 CMP #TRUE
 BNE BFEOUT
 LDA KERCHR
 ORA #$80
 STA KERCHR
BFEOUT LDA FILMOD
 BNE BFEFPC
 LDA KERCHR
 AND #$7F
 CMP #CR
 BNE BFECLF
 LDA #ON
 STA DELLF
 JMP BFEFPC
BFECLF CMP #LF
 BNE BFENLF
 LDA DELLF
 CMP #ON
 BNE BFEFPC
 LDA #OFF
 STA DELLF
 JMP BFEOU1
BFENLF LDA #OFF
 STA DELLF
BFEFPC LDA KERCHR
 JSR FPUTC
  JMP BFEERR
 INC RCHR
 BNE BFEOU1
 INC RCHR+1
BFEOU1 INC DATIND
 JMP BFETOL
BFEERR STA ERRCOD
 AND #$7F
 TAY
 LDA #KERDEL
 PHA
 DEY
 DEY
 TYA
 PHA
 LDA #DSKERS
 STA KERMBS
 LDA #<DSKERS
 STA KERMBS+1
 JSR GENMAD
 JSR PRSTR
 LDA #FALSE
 RTS
GETNFL LDA #EOF
 RTS
GETFIL LDA USEHDR
 CMP #ON
 BNE GETFL1
 LDY #$00
 LDA PDLEN
 SEC
 SBC #$03
 STA KWRK02
GETFL0 LDA (KERBF1),Y
 ORA #$80
 STA FCB1,Y
 INY
 CPY PDLEN
 BMI GETFL0
GETFL1 RTS
FGETC LDA ADDLF
 CMP #ON
 BNE FGETC1
 LDA #OFF
 STA ADDLF
 LDA #HLF
 JMP FGTGN1
FGETC1 LDX DSBIND
 CPX DSBEND
 BPL FGETC2
 JMP FGTGNC
FGETC2 LDA EODIND
 CMP #ON
 BNE FGTC2A
 JMP FGTEOF
FGTC2A LDA #FNCREA
 STA OPCOD
 LDA #$00
 STA RNGLNH
 LDA #MXDB-1
 STA RNGLNL
 LDA #SFNTRN
 STA SUBCOD
 LDA #DOSBUF
 STA FNADRL
 LDA #<DOSBUF
 STA FNADRH
 JSR DOSFMN
 LDA FMRCOD
 CMP #DSENER
 BEQ FGTSET
 CMP #DSEEOD
 BEQ FGETC3
 JMP FGTCAN
FGETC3 LDA #MXDB-2
 SEC
 SBC RNGLNL
 BEQ FGTEOF
 STA DSBEND
 LDA #$00
 STA DSBIND
 JMP FGTGNC
 JMP FGTGNC
FGTSET LDA #$00
 STA DSBIND
 LDA #MXDB-1
 STA DSBEND
 LDA FETFL
 CMP #ON
 BNE FGTGNC
 LDX #$00
 LDA FILMOD
 CMP #$04
 BNE FGTST1
 INX
 INX
FGTST1 LDA DOSBUF,X
 STA FILLEN
 INX
 LDA DOSBUF,X
 STA FILLEN+1
 LDX #$02
 LDA FILMOD
 CMP #$04
 BNE FGTST2
 INX
 INX
FGTST2 STX KWRK01
 CLC
 LDA FILLEN
 ADC KWRK01
 STA FILLEN
 LDA FILLEN+1
 ADC #$00
 STA FILLEN+1
 LDA #OFF
 STA FETFL
FGTGNC LDX DSBIND
 LDA DOSBUF,X
 INC DSBIND
FGTGN1 LDX FBSIZE
 CPX #FBSBIT
 BNE FGTEXI
 AND #$7F
FGTEXI JMP RSKP
FGTEOF LDA #TRUE
 STA EOFINP
 LDA #$00
 RTS
FGTCAN JMP FATAL
FPUTC LDX FBSIZE
 CPX #FBSBIT
 BNE FPTSTC
 ORA #$80
FPTSTC LDX DSBIND
 STA DOSBUF,X
 INC DSBIND
 LDA DSBIND
 CMP #MXDB
 BEQ FPTWRT
 LDA #$00
 JMP RSKP
FPTWRT LDA #FNCWRT
 STA OPCOD
 LDA #$00
 STA RNGLNH
 LDA #MXDB-1
 STA RNGLNL
 LDA #SFNTRN
 STA SUBCOD
 LDA #DOSBUF
 STA FNADRL
 LDA #<DOSBUF
 STA FNADRH
 JSR DOSFMN
 LDA FMRCOD
 CMP #DSENER
 BEQ FPTRST
 JMP FATAL
FPTRST LDA #MXDB-1
 STA DSBEND
 LDA #$00
 STA DSBIND
 JMP RSKP
INCN PHA
 LDA N
 CLC
 ADC #$01
 AND #$3F
 STA N
 PLA
 RTS
GOBBLE LDA #$00
 STA PDTEND
GOBB0 JSR GETC
  JMP GOBB1
 CMP REOL
 BEQ GOBB2
 LDX PDTEND
 STA PLNBUF,X
 INC PDTEND
 JMP GOBB0
GOBB1 RTS
GOBB2 LDA #$00
 STA PDTIND
 JMP RSKP
GETPLC LDX PDTIND
 CPX PDTEND
 BMI GETPL1
 RTS
GETPL1 LDA PLNBUF,X
 INC PDTIND
 JMP RSKP
GETC JSR TELCK
 CMP #FALSE
 BEQ GETC1
 LDA KBD
 AND #$7F
 CMP #'Q
 BNE GETC0
 LDA #$08
 STA ERRCOD
 LDX KEROSP
 TXS
 JMP KERMIT
GETC0 BIT KBDSTR
 RTS
GETC1 JSR TELCP
 CMP #FALSE
 BEQ GETC
 JSR TELGPC
 JMP RSKP
TELCK BIT KBD
 BPL TELCKF
 LDA #TRUE
 RTS
TELCKF LDA #FALSE
 RTS
PRSON LDA #ONCMD
 STA CMINF1
 LDA #<ONCMD
 STA CMINF1+1
 LDA #CMKEY
 JSR COMND
  RTS
  NOP
  NOP
 JMP RSKP
PRCFM LDA #CMCFM
 JSR COMND
  JMP KERMT3
 LDA #HCR
 JSR COUT
 RTS
PRON CMP #ON
 BNE PRON1
 LDX #SHON
 LDY #<SHON
PRON0 JSR PRSTR
 JSR PRCRLF
 RTS
PRON1 LDX #SHOFF
 LDY #<SHOFF
 JMP PRON0
NONFTL LDA FMRCOD
 ORA #$80
 STA ERRCOD
 LDX KEROSP
 TXS
 JMP KERMIT
FATAL LDA FMRCOD
 ORA #$80
 STA ERRCOD
 LDA #$01
 JSR CLOSEF
 JSR DOSDEL
 LDX KEROSP
 TXS
 JMP KERMIT
PRCHR ORA #$80
 CMP #$9B
 BPL PRCHR1
 TAX
 LDA #'^
 ORA #$80
 JSR COUT
 TXA
 CLC
 ADC #$40
 JSR COUT
 RTS
PRCHR1 BNE PRCHR2
 LDA #'$
 ORA #$80
 JSR COUT
 RTS
PRCHR2 JSR COUT
 RTS
GENMAD PLA
 STA KERRTA
 PLA
 STA KERRTA+1
 PLA
 TAX
 PLA
 TAY
 LDA #$00
 PHA
 TXA
 PHA
 LDA #$00
 PHA
 TYA
 PHA
 JSR MUL16
 PLA
 CLC
 ADC KERMBS
 TAX
 PLA
 ADC KERMBS+1
 TAY
 LDA KERRTA+1
 PHA
 LDA KERRTA
 PHA
 RTS
SPAR LDY #$00
 STY DATIND
 LDA RPSIZ
 CLC
 ADC #$20
 STA (KERBF1),Y
 INY
 LDA RTIME
 CLC
 ADC #$20
 STA (KERBF1),Y
 INY
 LDA RPAD
 CLC
 ADC #$20
 STA (KERBF1),Y
 INY
 LDA RPADCH
 EOR #$40
 STA (KERBF1),Y
 INY
 LDA REOL
 CLC
 ADC #$20
 STA (KERBF1),Y
 INY
 LDA RQUOTE
 STA (KERBF1),Y
 INY
 LDA UVAREBQ
 STA (KERBF1),Y
 RTS
RPAR LDY #$00
 LDA (KERBF1),Y
 SEC
 SBC #$20
 STA SPSIZ
 INY
 LDA (KERBF1),Y
 SEC
 SBC #$20
 STA STIME
 INY
 LDA (KERBF1),Y
 SEC
 SBC #$20
 STA SPAD
 INY
 LDA (KERBF1),Y
 EOR #$40
 STA SPADCH
 INY
 LDA (KERBF1),Y
 CMP #$00
 BEQ RPAR2
 JMP RPAR3
RPAR2 LDA #CR
 STA SEOL
 JMP RPAR4
RPAR3 SEC
 SBC #$20
 STA SEOL
RPAR4 INY
 LDA (KERBF1),Y
 CMP #$00
 BEQ RPAR5
 JMP RPAR6
RPAR5 LDA #'#
RPAR6 STA SQUOTE
 INY
 LDA (KERBF1),Y
 STA UVASEBQ
 RTS
NAKIT LDA #$00
 STA PDLEN
 LDA #'N
 STA PTYPE
 JSR SPAK
 RTS
VERSIO ASC 'STEVENS - APPLE ][ KERMIT-65  -  VER 1.1' 1
 DFB 0
KERCMD DFB $09
 DFB $07
 ASC 'CONNECT'
 DFB 0
 DFB $00,$00
 DFB $04
 ASC 'EXIT'
 DFB 0
 DFB $03,$03
 DFB $04
 ASC 'HELP'
 DFB 0
 DFB $06,$06
 DFB $04
 ASC 'QUIT'
 DFB 0
 DFB $0C,$0C
 DFB $07
 ASC 'RECEIVE'
 DFB 0
 DFB $0F,$0F
 DFB $04
 ASC 'SEND'
 DFB 0
 DFB $12,$12
 DFB $03
 ASC 'SET'
 DFB 0
 DFB $15,$15
 DFB $04
 ASC 'SHOW'
 DFB 0
 DFB $18,$18
 DFB $06
 ASC 'STATUS'
 DFB 0
 DFB $1B,$1B
SETCMD DFB $0A
 DFB $09
 ASC 'DEBUGGING'
 DFB 0
 DFB $18,$18
 DFB $11
 ASC 'EIGHT-BIT-QUOTING'
 DFB 0
 DFB $15,$15
 DFB $06
 ASC 'ESCAPE'
 DFB 0
 DFB $00,$00
 DFB $0E
 ASC 'FILE-BYTE-SIZE'
 DFB 0
 DFB $1E,$1E
 DFB $09
 ASC 'FILE-MODE'
 DFB 0
 DFB $1B,$1B
 DFB $0C
 ASC 'FILE-WARNING'
 DFB 0
 DFB $12,$12
 DFB $0A
 ASC 'LOCAL-ECHO'
 DFB 0
 DFB $06,$06
 DFB $07
 ASC 'RECEIVE'
 DFB 0
 DFB $09,$09
 DFB $04
 ASC 'SEND'
 DFB 0
 DFB $0C,$0C
 DFB $0E
 ASC 'VT52-EMULATION'
 DFB 0
 DFB $0F,$0F
SHOCMD DFB $0B
 DFB $03
 ASC 'ALL'
 DFB 0
 DFB $00,$00
 DFB $09
 ASC 'DEBUGGING'
 DFB 0
 DFB $51,$51
 DFB $11
 ASC 'EIGHT-BIT-QUOTING'
 DFB 0
 DFB $48,$48
 DFB $06
 ASC 'ESCAPE'
 DFB 0
 DFB $09,$09
 DFB $0E
 ASC 'FILE-BYTE-SIZE'
 DFB 0
 DFB $63,$63
 DFB $09
 ASC 'FILE-MODE'
 DFB 0
 DFB $5A,$5A
 DFB $0C
 ASC 'FILE-WARNING'
 DFB 0
 DFB $3F,$3F
 DFB $0A
 ASC 'LOCAL-ECHO'
 DFB 0
 DFB $1B,$1B
 DFB $07
 ASC 'RECEIVE'
 DFB 0
 DFB $24,$24
 DFB $04
 ASC 'SEND'
 DFB 0
 DFB $2D,$2D
 DFB $0E
 ASC 'VT52-EMULATION'
 DFB 0
 DFB $36,$36
STSCMD DFB $07
 DFB $14
 ASC 'EIGHT-BIT-QUOTE-CHAR'
 DFB 0
 DFB $06,$06
 DFB $0B
 ASC 'END-OF-LINE'
 DFB 0
 DFB $09,$09
 DFB $0D
 ASC 'PACKET-LENGTH'
 DFB 0
 DFB $0C,$0C
 DFB $08
 ASC 'PAD-CHAR'
 DFB 0
 DFB $00,$00
 DFB $07
 ASC 'PADDING'
 DFB 0
 DFB $03,$03
 DFB $0A
 ASC 'QUOTE-CHAR'
 DFB 0
 DFB $0F,$0F
 DFB $07
 ASC 'TIMEOUT'
 DFB 0
 DFB $12,$12
FTCMD DFB $05
 DFB $09
 ASC 'APPLESOFT'
 DFB 0
 DFB $02,$02
 DFB $06
 ASC 'BINARY'
 DFB 0
 DFB $04,$04
 DFB $07
 ASC 'INTEGER'
 DFB 0
 DFB $01,$01
 DFB $04
 ASC 'TEXT'
 DFB 0
 DFB $00,$00
 DFB 5
 ASC 'ASCII'
 DFB 0
 DFB 5,5
FBSKEY DFB $02
 DFB $09
 ASC 'EIGHT-BIT'
 DFB 0
 DFB $00,$00
 DFB $09
 ASC 'SEVEN-BIT'
 DFB 0
 DFB $01,$01
ONCMD DFB $02
 DFB $02
 ASC 'ON'
 DFB 0
 DFB $01,$01
 DFB $03
 ASC 'OFF'
 DFB 0
 DFB $00,$00
YESCMD DFB $02
 DFB $02
 ASC 'NO'
 DFB 0
 DFB $00,$00
 DFB $03
 ASC 'YES'
 DFB 0
 DFB $01,$01
KERHLP DFB HCR
 ASC 'KERMIT COMMANDS FOR THIS VERSION ARE' 0
 DFB HCR
 DFB HCR
 ASC 'EXIT    EXIT  FROM  KERMIT  BACK	TO' 0
 DFB HCR
 ASC '	      THE  HOST OPERATING  SYSTEM.' 0
 DFB HCR
 DFB HCR
 ASC 'HELP    PRINT    INSTRUCTIONS	ON' 0
 DFB HCR
 ASC '	      VARIOUS  COMMANDS  AVAILABLE' 0
 DFB HCR
 ASC '	      IN KERMIT.' 0
 DFB HCR
 DFB HCR
 ASC 'QUIT    SAME AS EXIT.' 0
 DFB HCR
 DFB HCR
 ASC 'CONNECT EMULATE A DUMB TERMINAL'
 DFB HCR,HCR
 ASC 'RECEIVE RECEIVE A FILE OR FILE GROUP' 0
 DFB HCR
 ASC '	      FROM THE REMOTE HOST.' 0
 DFB HCR
 DFB HCR
 ASC 'SEND    SENDS A FILE FROM THE  M6502' 0
 DFB HCR
 ASC '	      BASED COMPUTER TO THE REMOTE' 0
 DFB HCR
 ASC '	      HOST.' 0
 DFB HCR
 DFB HCR
 ASC 'SET     ESTABLISH VARIOUS PARAMETERS,' 0
 DFB HCR
 ASC '	      SUCH AS DUBBUGING MODE,  EOL' 0
 DFB HCR
 ASC '	      CHARACTER, AND  TRANSMISSION' 0
 DFB HCR
 ASC '	      DELAY.' 0
 DFB HCR
 DFB HCR
 ASC 'SHOW    DISPLAY  VARIOUS	PARAMETERS' 0
 DFB HCR
 ASC '	      ESTABLISHED   BY	 THE   SET' 0
 DFB HCR
 ASC '	      COMMAND.' 0
 DFB HCR
 DFB HCR
 ASC 'STATUS  GIVE  INFORMATION ABOUT  THE' 0
 DFB HCR
 ASC '	      LAST FILE TRANSFER.' 0
 DFB HCR,NUL
INTHLP ASC 'ONE OF THE FOLLOWING' 0
 DFB HCR
 ASC '	   ? - THIS HELP MESSAGE' 0
 DFB HCR
 ASC '	   C - CLOSE THE CONNECTION' 0
 DFB HCR
 ASC '	   S - STATUS' 0
 DFB HCR,NUL
ERMES1 DFB HCR
 ASC '?UNRECOGNIZED COMMAND' 1
 DFB 0
ERMES2 DFB HCR
 ASC '?ILLEGAL CHARACTER' 1
 DFB 0
ERMES3 DFB HCR
 ASC '?NOT CONFIRMED' 1
 DFB 0
ERMES4 DFB HCR
 ASC '?INTEGER OUT OF RANGE' 1
 DFB 0
ERMES5 DFB HCR
 ASC '?ASCII CHARACTER IS NOT IN PROPER RANGE' 1
 DFB 0
ERMES6 DFB HCR
 ASC '?EXPECTING KEYWORD' 1
 DFB 0
ERMES7 DFB HCR
 ASC '?EXPECTING FILE SPEC' 1
 DFB 0
ERMES8 DFB HCR
 ASC '?EXPECTING INTEGER' 1
 DFB 0
ERMES9 DFB HCR
 ASC '?EXPECTING SWITCH' 1
 DFB 0
ERMS0A ASC '			    ' 1
 DFB 0
ERMS10 ASC 'CANNOT RECEIVE INIT     ' 1
 DFB 0
ERMS11 ASC 'CANNOT RECEIVE FILE-HEAD' 1
 DFB 0
ERMS12 ASC 'CANNOT RECEIVE DATA     ' 1
 DFB 0
ERMS14 ASC 'MAX RETRY COUNT EXCEEDED' 1
 DFB 0
ERMS15 ASC 'BAD CHKSUMPACK, ACTUAL ' 1
 DFB 0
ERMS16 ASC 'PROGRAM ERROR IN RPAK   ' 1
 DFB 0
ERMS17 ASC '8-BIT QUOTING REFUSED   ' 1
 DFB 0
ERMS18 ASC 'TRANSFER ABORTED BY USER' 1
 DFB 0
ERMS19 ASC 'CANNOT ALTER FILENAME   ' 1
 DFB 0
ERMS1A ASC 'FILE ALREADY EXISTS     ' 1
 DFB 0
DSKERS ASC '			    ' 1
 DFB 0
 ASC 'BAD CALL TYPE	      ' 1
 DFB 0
 ASC 'BAD SUB-CALL TYPE       ' 1
 DFB 0
 ASC 'WRITE PROTECTED	      ' 1
 DFB 0
 ASC 'END OF DATA	      ' 1
 DFB 0
 ASC 'FILE NOT FOUND	      ' 1
 DFB 0
 ASC 'VOLUME MISMATCH	      ' 1
 DFB 0
 ASC 'DISK I/O		      ' 1
 DFB 0
 ASC 'DISK FULL 	      ' 1
 DFB 0
 ASC 'FILE LOCKED	      ' 1
 DFB 0
KERFTP ASC 'TEXT      ' 1
 DFB 0
 ASC 'INTEGER	' 1
 DFB 0
 ASC 'APPLESOFT ' 1
 DFB 0
 ASC 'BINARY	' 1
 DFB 0
KERRTS ASC 'SPAK     SENDING	       - ' 1
 DFB 0
 ASC 'SPAKCH   SEND COMPLETE	 - ' 1
 DFB 0
 ASC 'RPAK     TRYING TO RECEIVE - ' 1
 DFB 0
 ASC 'RPKFLS   FAILED TO RECEIVE - ' 1
 DFB 0
 ASC 'RPKRET   RECEIVED 	 - ' 1
 DFB 0
DEBMS1 ASC 'ADDITIONAL DATA' 1
 DFB 0
DEBMS2 ASC '	 SEQ NUMBER	      ' 1
 DFB 0
DEBMS3 ASC '	 NUMBER OF DATA CHARS ' 1
 DFB 0
DEBMS4 ASC '	 PACKET CHECKSUM      ' 1
 DFB 0
SNIN01 ASC 'SENDING... PACKET NUMBER ' 1
 DFB 0
RCIN01 ASC 'WAITING... PACKET NUMBER ' 1
 DFB 0
SHIN00 ASC 'DEBUGGING IS		' 1
 DFB 0
SHIN01 ASC 'VT52-EMULATION IS		' 1
 DFB 0
SHIN02 ASC 'IBM-MODE IS 		' 1
 DFB 0
SHIN03 ASC 'LOCAL-ECHO IS		' 1
 DFB 0
SHIN04 ASC 'EIGHT-BIT-QUOTING IS	' 1
 DFB 0
SHIN05 ASC 'FILE-WARNING IS		' 1
 DFB 0
SHIN06 ASC 'ESCAPE CHARACTER IS 	' 1
 DFB 0
SHIN07 ASC 'SEND' 1
 DFB 0
SHIN08 ASC '	 EIGHT-BIT-QUOTING CHAR IS   ' 1
 DFB 0
SHIN09 ASC '	 END-OF-LINE CHAR IS	     ' 1
 DFB 0
SHIN10 ASC '	 PACKET-LENGTH IS	     ' 1
 DFB 0
SHIN11 ASC '	 PADDING CHAR IS	     ' 1
 DFB 0
SHIN12 ASC '	 AMOUNT OF PADDING IS	     ' 1
 DFB 0
SHIN13 ASC '	 QUOTE CHAR IS		     ' 1
 DFB 0
SHIN14 ASC '	 TIMEOUT CHAR IS	     ' 1
 DFB 0
SHIN15 ASC 'RECEIVE' 1
 DFB 0
SHIN16 ASC 'FILE-MODE IS		' 1
 DFB 0
SHIN17 ASC 'FILE-BYTE-SIZE IS		' 1
 DFB 0
SHON ASC 'ON' 1
 DFB 0
SHOFF ASC 'OFF' 1
 DFB 0
SHSBIT ASC 'SEVEN-BIT' 1
 DFB 0
SHEBIT ASC 'EIGHT-BIT' 1
 DFB 0
STIN00 ASC 'NUMBER OF DATA CHARS SENT IS     ' 1
 DFB 0
STIN01 ASC 'NUMBER OF DATA CHARS RECVED IS  ' 1
 DFB 0
STIN02 ASC 'TOTAL NUMBER OF CHARS SENT IS    ' 1
 DFB 0
STIN03 ASC 'TOTAL NUMBER OF CHARS RECVED IS ' 1
 DFB 0
STIN04 ASC 'OVERHEAD FOR SEND PACKETS IS     ' 1
 DFB 0
STIN05 ASC 'OVERHEAD FOR RECEIVE PACKETS IS  ' 1
 DFB 0
STIN06 ASC 'LAST ERROR ENCOUNTERED IS	     ' 1
 DFB 0
INF01A ASC '[CONNECTING TO HOST TYPE ' 1
 DFB 0
INF01B ASC 'C TO RETURN]' 1
 DFB 0
