💾 Archived View for mirrors.apple2.org.za › archive › www.textfiles.com › apple › ANATOMY › cmd.inte… captured on 2024-08-19 at 03:01:30.

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

 AVAILABLE'
 DCI 'RANGE ERROR'
 DCI 'WRITE PROTECTED'
 DCI 'END OF DATA'
 DCI 'FILE NOT FOUND'
 DCI 'VOLUME MISMATCH'
 DCI 'I/O ERROR'
 DCI 'DISK FULL'
 DCI 'FILE LOCKED'
 DCI 'SYNTAX ERROR'
 DCI 'NO BUFFERS AVAILABLE'
 DCI 'FILE TYPE MISMATCH'
 DCI 'PROGRAM TOO LARGE'
 DCI 'NOT DIRECT COMMAND'
 HEX 8D

EMSGOFFS HEX 0003191924333E4C5B646D788498AABB

BUFADR DS 2
CURSTAT DS 1
CSWSTATE DS 1
CSWL DS 2
KSWL DS 2
MAXFILES DS 2
SSAVE DS 1
XSAVE DS 1
YSAVE DS 1
ASAVE DS 1
CMDLNIDX DS 1
MONFLGS DS 1
CMDINDX DS 1
LOADLEN DS 2
PENDCMD DS 1
TEMP1 DS 1
KYWRDIDX DS 1
KYWRDFND DS 1
VOLVAL DS 2
DRVAL DS 2
SLOTVAL DS 2
LENVAL DS 2
RECVAL DS 2
BYTVAL DS 2
ADRVAL DS 2
MONVAL DS 1
FNAME DS 30
SFNAME DS 30
MXFLS HEX 03
CTLD HEX 84
EXFLG DS 1
EXCBUF DS 2
WHCBASIC DS 1
RUNINTRC DS 1
LAAB7 ASC "APPLESOFT"

LAAC1 DA $B7E8
LAAC3 DA $B3BB
LAAC5 DA $B4BB
LACC7 DA $C000

RV = $B7EA
IOBSLOT = $B7E9
AJUSTBYT = $BFDC
SETWARM = $BFE6
ROM = $C081
RAM = $C080

JMPFPST = $D43C
SETFPPR = $D4F2
NEWSTT = $D7D2
JPFPERR = $D865

BASWRM = $E003
BASCLD = $E000
INTERR = $E3E3
IRUN = $E836

OLDBRK = $FA59
INPRT = $FE8B
OUTPRT = $FE95
RTS = $FF58
MON = $FF65

 ORG $9D00

DBUFP DA DBUF-1
DOSKBD DA KBDINTR
DOSVID DA VIDINTRC
PFNADR DA FNAME
SFNADR DA SFNAME
LDRNGLEN DA LOADLEN
LOADADR DA $9D00
FMPARMS DA FMOP

CSWSTADR DA CSWST-1
 DA CSWST3-1
 DA CSWST4-1
 DA CSWST5-1
 DA CSWST6-1
 DA CSWST7-1
 DA CSWST8-1

 ORG $9D1E

CMDTBL DA DOINIT-1
 DA DOLOAD-1
 DA DOSAVE-1
 DA DORUN-1
 DA DOCHAIN-1
 DA DODELETE-1
 DA DOLOCK-1
 DA DOUNLCK-1
 DA DOCLOSE-1
 DA DOREAD-1
 DA DOEXEC-1
 DA DOWRITE-1
 DA DOPTION-1
 DA DOOPEN-1
 DA DOAPND-1
 DA DORENAME-1
 DA DOCAT-1
 DA DOMON-1
 DA DONOMON-1
 DA DOPRNUM-1
 DA DOINNUM-1
 DA DOMXFLS-1
 DA DOFP-1
 DA DOINT-1
 DA DOBSAVE-1
 DA DOBLOAD-1
 DA DOBRUN-1
 DA DOVERIFY-1

 ORG $9D55

CHNADR DA IRUN
RUNADR DA DOSIRUN
BASERR DA INTERR
BASCOLD DA BASCLD
BASWARM DA BASWRM
ASFTREL DA SETFPPR

INTTBL DA IRUN
 DA DOSIRUN
 DA INTERR
 DA BASCLD
 DA BASWRM

FPTBL DA DOSARUN
 DA DOSARUN
 DA JPFPERR
 DA BASCLD
 DA JMPFPST
 DA SETFPPR

RAMASTBL DA DOSA2RUN
 DA DOSA2RUN
 DA L1067
 DA DOSSTRT
 DA LC3C
 DA LCF2

 ORG $9D84

DOSSTRT LDA IOBSLOT
 LSR 
 LSR 
 LSR 
 LSR 
 STA SLOTVAL
 LDA IOBDRV
 STA DRVAL

 LDA BASCLD
 EOR #$20
 BNE LDFPBAS

 STA WHCBASIC
 LDX #$A
LDINT LDA INTTBL-1,X
 STA CHNADR-1,X
 DEX 
 BNE LDINT
 JMP CHSBASIC

LDFPBAS LDA #$40
 STA WHCBASIC
 LDX #$C
LDFPTBL LDA FPTBL-1,X
 STA CHNADR-1,X
 DEX 
 BNE LDFPTBL
CHSBASIC SEC 
 BCS INITDOS

 ORG $9DBF

DOSWARM LDA WHCBASIC
 BNE DOSWARM1

 LDA #$20
 BNE DOSWARM2
DOSWARM1 ASL
 BPL DOSWARM3

 LDA #$4C
DOSWARM2 JSR SETBASIC
DOSWARM3 CLC

 ORG $9DD1

INITDOS PHP 
 JSR INITPTR
 LDA #$0 ;set NOMON O,I,C
 STA MONFLGS
 STA CSWSTATE ;init to state 0
 PLP 
 ROR 
 STA CURSTAT
 BMI INITDOS1
 JMP (BASWARM)
INITDOS1 JMP (BASCOLD)

FRSTIME ASL ;check for RAM or ROM A/S
 BPL MVRAMAS2

 STA WHCBASIC
 LDX #$C
MVRAMAS LDA RAMASTBL-1,X
 STA CHNADR-1,X
 DEX 
 BNE MVRAMAS
 LDX #$1D
MVRAMAS1 LDA SFNAME,X
 STA FNAME,X
 DEX 
 BPL MVRAMAS1

 ORG $9E06

MVRANAS2 LDA MXFLS
 STA MAXFILES

 JSR INITBUFS

 LDA EXFLG
 BEQ MVRAMAS3
 PHA 
 JSR PNTEXEC
 PLA 
 LDY #0
 STA (FILEBUF),Y

MVRAMAS3 JSR RSET0

 LDA CMDINDX
 BNE TSTPEND

 LDX #$2F
MOV3D0 LDA PAG3,X
 STA DOSRST,X
 DEX 
 BPL MOV3D0
 LDA PAG3+2
 STA SOFTEV+1
 EOR #$A5
 STA PWREDUP
 LDA PAG3+1
 STA SOFTEV
 LDA #$6
 BNE TSTPEND1

TSTPEND LDA PENDCMD
 BEQ TSTPEND2
TSTPEND1 STA CMDINDX
 JMP DOCMD
TSTPEND2 RTS

 ORG $9E51

PAG3 JMP DOSWARM
 JMP DOSSTRT
 JMP FMGR2
 JMP CALLRWTS
 LDA FMPARMS+1
 LDY FMPARMS
 RTS 
 LDA LAAC1+1
 LDY LAAC1
 RTS 
 JMP INITPTR
 NOP 
 NOP 
 JMP OLDBRK
 JMP MON
 JMP RTS
 JMP MON
 JMP MON
 DA $FF65

 ORG $9E81

KBDINTR JSR SAVREG
 LDA CURSTAT ;reading from a file?
 BEQ KBDINTR2

 PHA 
 LDA ASAVE
 STA (BASE),Y
 PLA 
 BMI KBDINTR1 ;doing coldstart?
 JMP READBYTE

 ORG $9E95

KBDINTR1 JSR FRSTIME
 LDY CH
 LDA #$60
 STA (BASE),Y
KBDINTR2 LDA EXFLG
 BEQ KBDINTR3
 JSR EXECRD
KBDINTR3 LDA #3
 STA CSWSTATE
 JSR REGRST
 JSR RDCHAR
 STA ASAVE
 STX XSAVE
 JMP DOSXIT
RDCHAR JMP (KSW)

 ORG $9EBD

VIDINTRC JSR SAVREG
 LDA CSWSTATE
 ASL 
 TAX 
 LDA CSWSTADR+1,X
 PHA 
 LDA CSWSTADR,X
 PHA 
 LDA ASAVE
 RTS ;Funny JMP (--)

 ORG $9ED1

SAVREG STA ASAVE
 STX XSAVE
 STY YSAVE
 TSX 
 INX 
 INX 
 STX SSAVE
 LDX #3
SAVREG1 LDA CSWL,X
 STA CSW,X
 DEX 
 BPL SAVREG1
 RTS 

 ORG $9EEB

CSWST LDX RUNINTRC
 BEQ CSWST1
 JMP RUNDONE

CSWST1 LDX CURSTAT
 BEQ CSWST2

 CMP #"?" ;A/S PROMPT
 BEQ CSWST8

 CMP PROMPT
 BEQ CSWST4A

CSWST2 LDX #2
 STX CSWSTATE
 CMP CTLD
 BNE CSWST4
 DEX 
 STX CSWSTATE
 DEX 
 STX CMDLNIDX

CSWST3 LDX CMDLNIDX
C1LP STA IN,X
 INX 
 STX CMDLNIDX
 CMP #$8D
 BNE ECHOC
 JMP PARSE

 ORG $9F23

CSWST4 CMP #$8D
 BNE ECHO
CSWST4A LDX #0
 STX CSWSTATE
 JMP ECHO

 ORG $9F2F

CSWST5 LDX #0
 STX CSWSTATE
 CMP #$8D
 BEQ CSWST5A

C3CHKEXC LDA EXFLG
 BEQ ECHO
 BNE ECHOI

CSWST5A PHA
 SEC 
 LDA EXFLG
 BNE CSWST5B
 JSR ISBASRUN
CSWST5B PLA
 BCC C3CHKEXC
 LDX XSAVE
 JMP C1LP

 ORG $9F52

CSWST6 CMP #$8D
 BNE CSWST6A
 LDA #5
 STA CSWSTATE
CSWST6A JSR WRTBYTE
 JMP ECHOO

 ORG $9F61

CSWST7 CMP CTLD
 BEQ CSWST

 CMP #$8A
 BEQ CSWST6A

 LDX #4
 STX CSWSTATE
 BNE CSWST6

 ORG $9F71

CSWST8 LDA #0
 STA CSWSTATE
 BEQ ECHOI

 ORG $9F78

RUNDONE LDA #0
 STA RUNINTRC
 JSR INITPTR
 JMP DORUN2

SCNXIT LDA IN
 CMP CTLD
 BEQ ECHOC
 LDA #$8D
 STA IN
 LDX #0
 STX XSAVE

 ORG $9F95

ECHOC LDA #$40
 BNE ECHOI1
ECHOO LDA #$10
 BNE ECHOI1
ECHOI LDA #$20
ECHOI1 AND MONFLGS
 BEQ DOSXIT
ECHO JSR REGRST
 JSR COUT
 STA ASAVE
 STY YSAVE
 STX XSAVE

 ORG $9FB3

DOSXIT JSR INITPTR
 LDX SSAVE
 TXS 
REGRST LDA ASAVE
 LDY YSAVE
 LDX XSAVE
 SEC 
 RTS 

 ORG $9FC5

COUT JMP (CSW)
CRLF LDA #$8D
 JMP COUT

 ORG $9FCD

PARSE LDY #$FF
 STY CMDINDX ;set to 0 (see ADDCHR)
 INY 
 STY PENDCMD

ADDCHR INC CMDINDX
 LDX #0
 PHP ;assume "="
 LDA IN,X ;skip any control-D's
 CMP CTLD
 BNE ADDCHR1
 INX 
ADDCHR1 STX CMDLNIDX
ADDCHR2 JSR FLSHCMDL ;skip blanks
 AND #$7F
 EOR DOSCMDS,Y ;compare to char in table
 INY 

 ASL 
 BEQ ADDCHR3
 PLA 
 PHP 
ADDCHR3 BCC ADDCHR2
 PLP 
 BEQ COMPIDX
 LDA DOSCMDS,Y
 BNE ADDCHR ;at last command?

GETFRST LDA IN
 CMP CTLD
 BEQ GETFRST1
 JMP ECHO
GETFRST1 LDA IN+1
 CMP #$8D
 BNE GETFRST2
 JSR RSET0
 JMP ECHOC
GETFRST2 JMP CSYNERR

 ORG $A01B

COMPIDX ASL CMDINDX
 LDY CMDINDX
 JSR ISBASRUN
 BCC COMPIDX1

 LDA #2
 AND KWRDPRMS,Y
 BEQ COMPIDX1

 LDA #$F
 JMP DOERROR

COMPIDX1 CPY #6
 BNE COMPIDX2
 STY PROMPT

COMPIDX2 LDA #$20
 AND KWRDPRMS,Y
 BEQ FNDNNAM

 JSR BLKNAME
 PHP 

CMDINP JSR FLSHCMDL
 BEQ CLRNAME3
 ASL 
 BCC CMDINP1
 BMI CMDINP1
 JMP GETFRST
CMPINP1 ROR
 JMP CLRNAME1
CLRNAME JSR GNXTCHR
 BEQ CLRNAME3
CLRNAME1 STA FNAME,Y
 INY 
 CPY #$3C
 BCC CLRNAME
CLRNAME2 JSR GNXTCHR
 BNE CLRNAME2
CLRNAME3 PLP
 BNE CLRNAME4
 LDY CMDINDX
 LDA #$10
 AND KWRDPRMS,Y
 BEQ CLRNAME5
 LDY #$1E
 PHP 
 BNE CMDINP
CLRNAME4 LDA SFNAME
 CMP #$A0
 BEQ CHKFRST
CLRNAME5 LDA FNAME
 CMP #$A0
 BNE SETDFLTS
 LDY CMDINDX
 LDA #$C0
 AND KWRDPRMS,Y
 BEQ CHKFRST
 BPL SETDFLTS
CHKFRST JMP GETFRST

 ORG $A095

BLKNAME LDY #$3C
 LDA #$A0
BLKNAME1 STA MONVAL,Y
 DEY 
 BNE BLKNAME1
 RTS 

 ORG $A0A0

FNDNNAM STA FNAME

 LDA #$C
 AND KWRDPRMS,Y
 BEQ SETDFLTS

 JSR GETNUM

 BCS FNDNNAM3
 TAY 
 BNE FNDNNAM2

 CPX #$11
 BCS FNDNNAM2
 LDY CMDINDX
 LDA #8
 AND KWRDPRMS,Y
 BEQ FNDNNAM1
 CPX #8
 BCS CHKFRST

 BCC SETDFLTS
FNDNNAM1 TXA
 BNE SETDFLTS
FNDNNAM2 LDA #2
 JMP DOERROR
FNDNNAM3 JMP CSYNERR

 ORG $A0D1

SETDFLTS LDA #0
 STA KYWRDFND
 STA MONVAL
 STA VOLVAL
 STA LENVAL
 STA LENVAL+1
 JSR AJUSTBYT
 LDA CMDLNIDX

GETNXT JSR FLSHCMDL
 BNE GETNXT1
 CMP #$8D
 BNE GETNXT

 LDX CMDINDX
 LDA KYWRDFND
 ORA KWRDPRMS+1,X
 EOR KWRDPRMS+1,X
 BNE CHKFRST
 LDX TEMP1
 BEQ PROCMD
 STA TEMP1
 STX CMDLNIDX
 BNE GETNXT
GETNXT1 LDX #$A
GETNXT2 CMP PPARMS-1,X
 BEQ ISLE1
 DEX
 BNE GETNXT2
ISLE BEQ FNDNNAM3

ISLE1 LDA PARMBITS-1,X
 BMI UPDATMON
 ORA KYWRDFND
 STA KYWRDFND
 DEX 
 STX KYWRDIDX

 JSR GETNUM
 BCS FNDNNAM3

 LDA KYWRDIDX
 ASL 
 ASL 
 TAY 
 LDA OPRND+1
 BNE ISLE2
 LDA OPRND
 CMP KWRANGE,Y
 BCC FNDNNAM2
 LDA OPRND+1
ISLE2 CMP KWRANGE+3,Y
 BCC ISLE4
ISLE3 BNE FNDNNAM2
 LDA OPRND
 CMP KWRANGE+2,Y
 BCC ISLE4
 BNE ISLE3
ISLE4 LDA TEMP1
 BNE GETNXT

 TYA 
 LSR 
 TAY 
 LDA OPRND+1
 STA VOLVAL+1,Y
 LDA OPRND
 STA VOLVAL,Y
GNISLE JMP GETNXT

 ORG $A164

UPDATMON PHA 
 LDA #$80
 ORA KYWRDFND
 STA KYWRDFND
 PLA 
 AND #$7F
 ORA MONVAL
 STA MONVAL
 BNE GNISLE
 BEQ ISLE

 ORG $A17A

PROCMD JSR DOCMD
 JMP SCNXIT
DOCMD JSR RSET0
 JSR CLRFMP
 LDA CMDINDX
 TAX 
 LDA CMDTBL+1,X
 PHA 
 LDA CMDTBL,X
 PHA 
 RTS 

 ORG $A193

GNXTCHR LDX CMDLNIDX
 LDA IN,X
 CMP #$8D
 BEQ GNXTCHR1
 INX 
 STX CMDLNIDX
 CMP #","
GNXTCHR1 RTS

 ORG $A1A4

FLSHCMDL JSR GNXTCHR
 BEQ GNXTCHR1
 CMP #$A0
 BEQ FLSHCMDL
 RTS 

 ORG $A1AE

CLRFMP LDA #0
 LDY #$16
CLRFMP1 STA FMOP-1,Y
 DEY
 BNE CLRFMP1
 RTS 

 ORG $A1B9

GETNUM LDA #0
 STA OPRND
 STA OPRND+1
 JSR FLSHCMDL
 PHP 
 CMP #"$"
 BEQ HEXCONV
 PLP 
 JMP GETNUM2

GETNUM1 JSR FLSHCMDL
GETNUM2 BNE GETNUM3
 LDX OPRND
 LDA OPRND+1
 CLC 
 RTS 

GETNUM3 SEC
 SBC #"0"
 BMI BADNUM
 CMP #$A
 BCS BADNUM

 JSR MUL2
 ADC OPRND
 TAX 
 LDA #0
 ADC OPRND+1
 TAY 
 JSR MUL2
 JSR MUL2
 TXA 
 ADC OPRND
 STA OPRND
 TYA 
 ADC OPRND+1
 STA OPRND+1
 BCC GETNUM1
BADNUM SEC 
 RTS 

MUL2 ASL OPRND
 ROL OPRND+1
 RTS 

 ORG $A203

HEXCONV PLP 
HEXLOOP JSR FLSHCMDL
 BEQ GETNUM2
 SEC 
 SBC #$B0
 BMI BADNUM
 CMP #$A
 BCC HEXLOOP1
 SBC #7
 BMI BADNUM
 CMP #$10
 BCS BADNUM
HEXLOOP1 LDX #4
HEXLOOP2 JSR MUL2
 DEX
 BNE HEXLOOP2
 ORA OPRND
 STA OPRND
 JMP HEXLOOP

 ORG $A229

DOPRNUM LDA OPRND
 JMP OUTPRT

 ORG $A22E

DOINNUM LDA OPRND
 JMP INPRT

 ORG $A233

DOMON LDA MONFLGS
 ORA MONVAL
 STA MONFLGS
 RTS 

DONOMON BIT MONVAL
 BVC DONOMON1
 JSR CRLF
DONOMON1 LDA #$70
 EOR MONVAL
 AND MONFLGS
 STA MONFLGS
 RTS 

 ORG $A251

DOMXFLS LDA #0
 STA EXFLG
 LDA OPRND
 PHA 
 JSR CLOSALL
 PLA 
 STA MAXFILES
 JMP INITBUFS

 ORG $A263

DODELETE LDA #5
 JSR CMDHNDL1 ;perform the delete.

 JSR LOCBUF
 LDY #0
 TYA 
 STA (FILEBUF),Y
 RTS 

 ORG $A271

DOLOCK LDA #7
 BNE DOUNLCK1
DOUNLCK LDA #8
DOUNLCK1 JSR CMDHNDL1
 JMP DOCLOSE

 ORG $A27D

DOVERIFY LDA #$C
 BNE DOUNLCK1

 ORG $A281

DORENAME LDA SFNADR
 STA NEWNAME
 LDA SFNADR+1
 STA NEWNAME+1
 LDA #9
 STA TEMP1
 JSR CLOSOPN
 JMP DOCLOSE

 ORG $A298

DOAPND JSR DOOPEN
DOAPND1 JSR RDTEXT
 BNE DOAPND1
 JMP APTCH2

 ORG $A2A3

DOOPEN LDA #0
 JMP OPENTST

 ORG $A2A8

CMDHNDLR LDA #1
CMDHNDL1 STA TEMP1
 LDA LENVAL
 BNE CMDHNDL2
 LDA LENVAL+1
 BNE CMDHNDL2
 LDA #1
 STA LENVAL
CMDHNDL2 LDA LENVAL
 STA RECNUM
 LDA LENVAL+1
 STA RECNUM+1

CLOSOPN JSR DOCLOSE
 LDA OPRND+1
 BNE CLOSOPN1
 JMP NOBUF
CLOSOPN1 STA FILEBUF+1
 LDA OPRND
 STA FILEBUF
 JSR COPFNAM
 JSR COPPTRS
 JSR COPYPARM
 LDA TEMP1
 STA FMOP
 JMP FMDRVR

 ORG $A2EA

DOCLOSE LDA FNAME
 CMP #$A0
 BEQ CLOSALL
 JSR LOCBUF
 BCS RTS0
 JSR CLOSFRE
 JMP DOCLOSE

 ORG $A2FC

CLOSFRE JSR ISEXBUF
 BNE CLOSFRE1
 LDA #0
 STA EXFLG
CLOSFRE1 LDY #0
 TYA 
 STA (FILEBUF),Y
 JSR COPPTRS
 LDA #2
 STA FMOP
 JMP FMDRVR

 ORG $A316

CLOSALL JSR FRSTBUF
 BNE CLOSALL2
CLOSALL1 JSR PTNXTBF
 BEQ RTS0
CLOSALL2 JSR ISEXBUF
 BEQ CLOSALL1
 JSR GFBFNAM
 BEQ CLOSALL1
 JSR CLOSFRE
 JMP CLOSALL
RTS0 RTS 

 ORG $A331

DOBSAVE LDA #9 ;check parameters
 AND KYWRDFND
 CMP #9
 BEQ DOBSAVE1
 JMP GETFRST

DOBSAVE1 LDA #4
 JSR OPENTST

 LDA ADRVAL+1
 LDY ADRVAL
 JSR WRT2
 LDA LENVAL+1
 LDY LENVAL
 JSR WRT2
 LDA ADRVAL+1
 LDY ADRVAL
 JMP RWRANGE

 ORG $A35D

DOBLOAD JSR CMDHNDLR

 LDA #$7F
 AND FILETYPE
 CMP #4
 BEQ DOBLOAD1
 JMP FMISMTCH
DOBLOAD1 LDA #4
 JSR OPENTST

 JSR READDBYT
 TAX 
 LDA KYWRDFND
 AND #1
 BNE DOBLOAD2
 STX ADRVAL
 STY ADRVAL+1
DOBLOAD2 JSR READDBYT
 LDX ADRVAL
 LDY ADRVAL+1
 JMP RWSETUP

 ORG $A38E

DOBRUN JSR DOBLOAD
 JSR INITPTR
 JMP (ADRVAL)

 ORG $A397

DOSAVE LDA WHCBASIC
 BEQ ISINT

 LDA PROTECT
 BPL DOSAVE1
 JMP PTOOBIG
DOSAVE1 LDA #2
 JSR OPENTST
 SEC 
 LDA ASPEND
 SBC ASPGMST
 TAY 
 LDA ASPEND+1
 SBC ASPGMST+1
 JSR WRT2
 LDA ASPGMST+1
 LDY ASPGMST
 JMP RWRANGE

ISINT LDA #1
 JSR OPENTST
 SEC 
 LDA INTHIMEM
 SBC INTSTRT
 TAY 
 LDA INTHIMEM+1
 SBC INTSTRT+1
 JSR WRT2
 LDA INTSTRT+1
 LDY INTSTRT
 JMP RWRANGE

 ORG $A3BC

OPENTST STA FILETYPE
 PHA 
 JSR CMDHNDLR
 PLA 
 JMP CHKTYPE

WRT2 STY RANGELEN
 STY DATARANG
 STA RANGELEN+1
 LDA #4
 STA FMOP
 LDA #1
 STA FMSUBOP
 JSR FMDRVR
 LDA RANGELEN+1
 STA DATARANG
 JMP FMDRVR

RWRANGE STY DATARANG
 STA DATARANG+1
 LDA #2
 JMP VFYPTCH
RWRANGE1 JSR FMDRVR
 JMP DOCLOSE
FTMIS JMP FMISMTCH

 ORG $A413

DOLOAD JSR CLOSALL
 JSR CMDHNDLR
 LDA #$23 ;is type INT, RAM A/S or ROM A/S?
 AND FILETYPE
 BEQ FTMIS
 STA FILETYPE
 LDA WHCBASIC
 BEQ DOLOAD2

 LDA #2
 JSR SLBASIC

 JSR READDBYT

 CLC 
 ADC ASPGMST
 TAX 
 TYA 
 ADC ASPGMST+1
 CMP ASHIMEM+1
 BCS PTOOLRG
 STA ASPEND+1
 STA ASVARS+1
 STX ASPEND
 STX ASVARS
 LDX ASPGMST
 LDY ASPGMST+1
 JSR RWSETUP
 JSR INITPTR
 JMP (ASFTREL)

DOLOAD2 LDA #1
 JSR SLBASIC
 JSR READDBYT
 SEC 
 LDA INTHIMEM
 SBC LOADLEN
 TAX 
 LDA INTHIMEM+1
 SBC LOADLEN+1
 BCC PTOOLRG
 TAY 
 CPY INTLOMEM+1
 BCC PTOOLRG
 BEQ PTOOLRG
 STY INTSTRT+1
 STX INTSTRT

RWSETUP STX DATARANG
 STY DATARANG+1
 JMP RWRANGE1

READDBYT LDA LDRNGLEN
 STA DATARANG
 LDA LDRNGLEN+1
 STA DATARANG+1
 LDA #0
 STA RANGELEN+1
 LDA #2
 STA RANGELEN
 LDA #3
 STA FMOP
 LDA #2
 STA FMSUBOP
 JSR FMDRVR
 LDA LOADLEN+1
 STA RANGELEN+1
 TAY 
 LDA LOADLEN
 STA RANGELEN
 RTS 

 ORG $A4AB

PTOOLRG JSR DOCLOSE
 JMP PTOOBIG

SLBASIC CMP FILETYPE
 BEQ RTS1

 LDX CMDINDX
 STX PENDCMD
 LSR 
 BEQ SLBASIC1
 JMP DOINT

SLBASIC1 LDX #$1D
SLBASIC2 LDA FNAME,X
 STA SFNAME,X
 DEX
 BPL SLBASIC2
 JMP DOFP
RTS1 RTS 


 ORG $A4D1

DORUN LDA WHCBASIC
 BEQ DORUN1
 STA RUNINTRC
DORUN1 JSR DOLOAD
DORUN2 JSR CRLF
 JSR INITPTR
 JMP (RUNADR)

 ORG $A4E5

DOSIRUN LDA INTLOMEM
 STA INTVEND
 LDA INTLOMEM+1
 STA INTVEND+1
 JMP (CHNADR)

 ORG $A4F0

DOCHAIN JSR DOLD2
 JSR CRLF
 JSR INITPTR
 JMP (CHNADR)

DOSARUN JSR LD665
 STA PROMPT
 STA ASONERR
 JMP NEWSTT
DOSA2RUN JSR LE65
 STA PROMPT
 STA ASONERR
 JMP LFD4

 ORG $A510

DOWRITE JSR RWCOMON
 LDA #5
 STA CSWSTATE
 JMP SCNXIT

 ORG $A51B

DOREAD JSR RWCOMON
 LDA #1
 STA CURSTAT
 JMP SCNXIT

RWCOMON JSR LOCBUF
 BCC RWCOMON1

 JSR DOOPEN
 JMP RWCOMON2

RWCOMON1 JSR COPPTRS

RWCOMON2 LDA KYWRDFND
 AND #6
 BEQ RTS2

 LDX #3
RWCOMON3 LDA RECVAL,X
 STA RECNUM,X
 DEX 
 BPL RWCOMON3

 LDA #$A
 STA FMOP
 JSR FMDRVR
RTS2 RTS 

 ORG $A54F

DOINIT LDA #$40
 AND KYWRDFND
 BEQ DOINIT1
 LDA VOLVAL
 BNE DOINIT2
DOINIT1 LDA #254
 STA VOLVAL

DOINIT2 LDA LOADADR+1
 STA FMSUBOP

 LDA #$B
 JSR CMDHNDL2
 JMP DOSAVE

 ORG $A56E

DOCAT LDA #6
 JSR CMDHNDL2


-end of file-