2019-04-17 15:31:18 +00:00
|
|
|
|
NEW
|
2019-05-02 09:52:32 +00:00
|
|
|
|
AUTO 3,1
|
2019-04-17 15:31:18 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
|
|
|
|
.TF BIN/WC
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
|
|
|
|
.INB INC/MLI.I
|
|
|
|
|
.INB INC/MLI.E.I
|
|
|
|
|
*--------------------------------------
|
2019-04-30 16:08:47 +00:00
|
|
|
|
X.ENTER.SUBDIR .EQ 0
|
2019-04-17 15:31:18 +00:00
|
|
|
|
X.COPY.TO.DEST .EQ 0
|
|
|
|
|
X.DELETE.SOURCE .EQ 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPBIN
|
|
|
|
|
ZS.START
|
|
|
|
|
ZPPtr1 .BS 2
|
|
|
|
|
ZPPtr2 .BS 2
|
|
|
|
|
ZPFileName .BS 2
|
|
|
|
|
ZPFileStat .BS 2
|
2019-09-20 15:15:06 +00:00
|
|
|
|
|
2019-04-17 15:31:18 +00:00
|
|
|
|
ZPFullPath .BS 2
|
2019-09-20 15:15:06 +00:00
|
|
|
|
ZPRelPath .BS 2
|
|
|
|
|
|
|
|
|
|
ZPLineBuf .BS 2
|
|
|
|
|
|
|
|
|
|
bPause .BS 1
|
|
|
|
|
|
|
|
|
|
bContinue .BS 1
|
|
|
|
|
bRecurse .BS 1
|
|
|
|
|
bChar .BS 1
|
|
|
|
|
bLine .BS 1
|
|
|
|
|
bWord .BS 1
|
|
|
|
|
bInWord .BS 1
|
|
|
|
|
bTotal .BS 1
|
|
|
|
|
|
2019-04-17 15:31:18 +00:00
|
|
|
|
ZS.END .ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA CS.END-CS.START Code Size (without Constants)
|
|
|
|
|
.DA DS.END-DS.START Data SegmentSize
|
|
|
|
|
.DA #64 Stack Size
|
|
|
|
|
.DA #ZS.END-ZS.START Zero Page Size
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
|
|
|
|
L.MSG.FILE .DA MSG.FILE
|
|
|
|
|
L.MSG.ERR .DA MSG.ERR
|
2019-09-20 15:15:06 +00:00
|
|
|
|
L.MSG.TOTAL .DA MSG.TOTAL
|
2019-04-17 15:31:18 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN >INC.G ArgIndex
|
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
bcs .8
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .4
|
2019-09-20 15:15:06 +00:00
|
|
|
|
jsr CS.RUN.CheckOpt
|
|
|
|
|
bcc CS.RUN
|
2019-04-17 15:31:18 +00:00
|
|
|
|
.9 >PUSHBI 0
|
|
|
|
|
>LDYA L.MSG.USAGE
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
lda #E.SYN
|
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.4 >LDA.G hSrcBasePath
|
|
|
|
|
bne .9
|
|
|
|
|
>LDYA ZPPtr1
|
|
|
|
|
jsr InitSrcDirYA
|
|
|
|
|
bcc CS.RUN
|
|
|
|
|
rts
|
|
|
|
|
.8 >LDA.G hSrcBasePath
|
|
|
|
|
beq .9
|
|
|
|
|
>LDYAI 256
|
|
|
|
|
>SYSCALL getmem
|
|
|
|
|
bcs .99
|
|
|
|
|
>STYA ZPFullPath
|
|
|
|
|
txa
|
|
|
|
|
>STA.G hSrcFullPath
|
2019-09-20 15:15:06 +00:00
|
|
|
|
|
|
|
|
|
>LDA.G hSrcBasePath
|
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
ldy #$ff
|
|
|
|
|
.80 iny
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
bne .80
|
|
|
|
|
tya
|
|
|
|
|
clc
|
|
|
|
|
adc ZPFullPath
|
|
|
|
|
sta ZPRelPath
|
|
|
|
|
lda ZPFullPath+1
|
|
|
|
|
adc #0
|
|
|
|
|
sta ZPRelPath+1
|
|
|
|
|
|
|
|
|
|
>LDYAI 256
|
|
|
|
|
>SYSCALL getmem
|
|
|
|
|
bcs .99
|
|
|
|
|
>STYA ZPLineBuf
|
|
|
|
|
txa
|
2019-10-03 06:25:27 +00:00
|
|
|
|
>STA.G hMem
|
2019-04-17 15:31:18 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.LOOP ldy #S.PS.hStdIn
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL feof
|
|
|
|
|
bcs .99
|
|
|
|
|
tay
|
2019-05-02 09:52:32 +00:00
|
|
|
|
bne .10
|
2019-04-17 15:31:18 +00:00
|
|
|
|
>SYSCALL GetChar
|
|
|
|
|
bcs .99
|
|
|
|
|
cmp #$03 Ctrl-C
|
|
|
|
|
beq .99 Abort....
|
|
|
|
|
cmp #$13 Ctrl-S
|
|
|
|
|
bne .10
|
|
|
|
|
|
2019-09-20 15:15:06 +00:00
|
|
|
|
lda bPause
|
2019-04-17 15:31:18 +00:00
|
|
|
|
eor #$ff
|
2019-09-20 15:15:06 +00:00
|
|
|
|
sta bPause
|
2019-04-17 15:31:18 +00:00
|
|
|
|
bne CS.RUN.LOOP
|
2019-09-20 15:15:06 +00:00
|
|
|
|
.10 lda bPause
|
2019-04-17 15:31:18 +00:00
|
|
|
|
bne CS.RUN.LOOP Pause...
|
2019-09-20 15:15:06 +00:00
|
|
|
|
|
2019-04-17 15:31:18 +00:00
|
|
|
|
jsr GetEntry
|
|
|
|
|
bcs .9
|
|
|
|
|
ldy #S.STAT.P.DRIVE
|
|
|
|
|
lda (ZPFileStat),y ProDOS Device ?
|
2019-09-20 15:15:06 +00:00
|
|
|
|
beq .5
|
2019-04-17 15:31:18 +00:00
|
|
|
|
jsr CS.RUN.DEV
|
|
|
|
|
bcc CS.RUN.LOOP
|
|
|
|
|
rts
|
|
|
|
|
.5 ldy #S.STAT.P.TYPE
|
|
|
|
|
lda (ZPFileStat),y
|
|
|
|
|
cmp #$0F Directory ?
|
|
|
|
|
bne .6
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.DIR
|
2019-09-20 15:15:06 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
bra .8
|
2019-04-17 15:31:18 +00:00
|
|
|
|
.6 jsr CS.RUN.FILE
|
2019-09-20 15:15:06 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
bra .8
|
2019-04-17 15:31:18 +00:00
|
|
|
|
|
|
|
|
|
.9 jsr LeaveSubDir
|
|
|
|
|
bcs .90
|
|
|
|
|
|
|
|
|
|
jsr BasePath..
|
|
|
|
|
.8 jsr GetNextEntry
|
|
|
|
|
jmp CS.RUN.LOOP
|
2019-09-20 15:15:06 +00:00
|
|
|
|
.90 jsr CS.RUN.PrintTstat
|
|
|
|
|
lda #0
|
2019-04-17 15:31:18 +00:00
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
2019-09-20 15:15:06 +00:00
|
|
|
|
CS.RUN.DIR lda bRecurse
|
|
|
|
|
bpl .8
|
|
|
|
|
lda (ZPFileName)
|
|
|
|
|
cmp #'.'
|
|
|
|
|
beq .8
|
|
|
|
|
>LDYA ZPFileName
|
|
|
|
|
jsr EnterSubDirYA
|
|
|
|
|
jmp CS.RUN.CheckErr
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
2019-04-17 15:31:18 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.DEV
|
|
|
|
|
.8 jsr GetNextEntry
|
2019-10-03 06:25:27 +00:00
|
|
|
|
clc
|
2019-04-17 15:31:18 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2019-04-30 16:08:47 +00:00
|
|
|
|
CS.RUN.FILE jsr FilterMatch
|
2019-04-17 15:31:18 +00:00
|
|
|
|
bcs .8 no match, skip....
|
2019-09-20 15:15:06 +00:00
|
|
|
|
|
2019-04-30 16:08:47 +00:00
|
|
|
|
jsr CS.RUN.GetFilePath
|
2019-09-20 15:15:06 +00:00
|
|
|
|
jsr CS.RUN.OpenFile
|
2019-04-17 15:31:18 +00:00
|
|
|
|
bcs .9
|
2019-09-20 15:15:06 +00:00
|
|
|
|
|
|
|
|
|
.1 >PUSHWI 256
|
|
|
|
|
>PUSHW ZPLineBuf
|
|
|
|
|
>LDA.G hFile
|
|
|
|
|
>SYSCALL fgets
|
|
|
|
|
bcs .6
|
|
|
|
|
jsr CS.RUN.IncFLine
|
|
|
|
|
ldy #$ff
|
|
|
|
|
stz bInWord
|
|
|
|
|
.2 iny
|
|
|
|
|
lda (ZPLineBuf),y
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
cmp #C.SPACE
|
|
|
|
|
beq .3
|
|
|
|
|
cmp #C.TAB
|
|
|
|
|
bne .4
|
|
|
|
|
.3 lda bInWord
|
|
|
|
|
beq .5
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.IncFWord
|
|
|
|
|
stz bInWord
|
|
|
|
|
bra .5
|
2019-10-03 06:25:27 +00:00
|
|
|
|
.4 inc bInWord
|
2019-09-20 15:15:06 +00:00
|
|
|
|
.5 jsr CS.RUN.IncFChar
|
|
|
|
|
bra .2
|
|
|
|
|
.6 cmp #MLI.E.EOF
|
|
|
|
|
bne .7
|
|
|
|
|
jsr CS.RUN.CloseFile
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.PrintFstat
|
|
|
|
|
bcs .99
|
|
|
|
|
jsr CS.RUN.AddFstat2Tstat
|
|
|
|
|
lda bTotal
|
|
|
|
|
bmi .8
|
|
|
|
|
beq .61
|
|
|
|
|
lda #$fe
|
|
|
|
|
.61 inc
|
|
|
|
|
sta bTotal
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.7 pha
|
|
|
|
|
jsr CS.RUN.CloseFile
|
|
|
|
|
pla
|
|
|
|
|
sec
|
|
|
|
|
.9 jmp CS.RUN.CheckErr
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.CheckErr bcc .9
|
|
|
|
|
pha
|
2019-04-17 15:31:18 +00:00
|
|
|
|
>PUSHA
|
|
|
|
|
>PUSHBI 1
|
|
|
|
|
>LDYA L.MSG.ERR
|
|
|
|
|
>SYSCALL printf
|
2019-09-20 15:15:06 +00:00
|
|
|
|
lda bContinue
|
2019-04-17 15:31:18 +00:00
|
|
|
|
eor #$80
|
|
|
|
|
asl
|
|
|
|
|
pla
|
2019-09-20 15:15:06 +00:00
|
|
|
|
.9 rts
|
2019-04-17 15:31:18 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.GetFilePath
|
|
|
|
|
>LDA.G hSrcBasePath
|
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>LDYA ZPFullPath
|
|
|
|
|
>SYSCALL StrCpy
|
|
|
|
|
>PUSHW ZPFileName
|
|
|
|
|
>LDYA ZPFullPath
|
|
|
|
|
>SYSCALL StrCat
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-09-20 15:15:06 +00:00
|
|
|
|
CS.RUN.OpenFile ldx #12
|
|
|
|
|
ldy #fCharCount
|
|
|
|
|
lda #0
|
|
|
|
|
.1 sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
>PUSHWZ Aux type
|
|
|
|
|
>PUSHBI 0 Type
|
|
|
|
|
>PUSHBI O.RDONLY+O.TEXT
|
|
|
|
|
>LDYA ZPFullPath
|
|
|
|
|
|
|
|
|
|
>SYSCALL FOpen
|
|
|
|
|
bcs .9
|
|
|
|
|
>STA.G hFile
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.CloseFile
|
|
|
|
|
>LDA.G hFile
|
|
|
|
|
>SYSCALL fclose
|
|
|
|
|
bcs .9
|
|
|
|
|
>STZ.G hFile
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.IncFChar phy
|
|
|
|
|
ldy #fCharCount
|
|
|
|
|
bra CS.RUN.IncF
|
|
|
|
|
|
|
|
|
|
CS.RUN.IncFLine phy
|
|
|
|
|
ldy #fLineCount
|
|
|
|
|
bra CS.RUN.IncF
|
|
|
|
|
|
|
|
|
|
CS.RUN.IncFWord phy
|
|
|
|
|
ldy #fWordCount
|
|
|
|
|
ldx #4
|
|
|
|
|
CS.RUN.IncF lda (pData),y
|
|
|
|
|
inc
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bne .8
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne CS.RUN.IncF
|
|
|
|
|
.8 ply
|
2019-10-03 06:25:27 +00:00
|
|
|
|
rts
|
2019-09-20 15:15:06 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.AddFstat2Tstat
|
|
|
|
|
>PUSHL.G fWordCount
|
|
|
|
|
>PUSHL.G tWordCount
|
|
|
|
|
>FPU ADD32
|
|
|
|
|
>PULLL.G tWordCount
|
|
|
|
|
>PUSHL.G fLineCount
|
|
|
|
|
>PUSHL.G tLineCount
|
|
|
|
|
>FPU ADD32
|
|
|
|
|
>PULLL.G tLineCount
|
|
|
|
|
|
|
|
|
|
>PUSHL.G fCharCount
|
|
|
|
|
>PUSHL.G tCharCount
|
|
|
|
|
>FPU ADD32
|
|
|
|
|
>PULLL.G tCharCount
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.PrintFstat
|
|
|
|
|
>PUSHW ZPRelPath
|
|
|
|
|
>PUSHL.G fWordCount
|
|
|
|
|
>PUSHL.G fLineCount
|
|
|
|
|
>PUSHL.G fCharCount
|
|
|
|
|
>PUSHBI 14
|
|
|
|
|
>LDYA L.MSG.FILE
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.PrintTstat
|
|
|
|
|
lda bTotal
|
|
|
|
|
bpl .8
|
|
|
|
|
>PUSHL.G tWordCount
|
|
|
|
|
>PUSHL.G tLineCount
|
|
|
|
|
>PUSHL.G tCharCount
|
|
|
|
|
>PUSHBI 12
|
|
|
|
|
>LDYA L.MSG.TOTAL
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2019-04-17 15:31:18 +00:00
|
|
|
|
CS.DOEVENT sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.QUIT jsr LeaveSubDir
|
|
|
|
|
bcc CS.QUIT
|
|
|
|
|
>LDA.G hFilter
|
|
|
|
|
beq .1
|
|
|
|
|
>SYSCALL FreeMem
|
|
|
|
|
.1 >LDA.G hSrcFullPath
|
2019-09-20 15:15:06 +00:00
|
|
|
|
beq .2
|
|
|
|
|
>SYSCALL FreeMem
|
|
|
|
|
.2 >LDA.G hMem
|
2019-04-17 15:31:18 +00:00
|
|
|
|
beq .8
|
|
|
|
|
>SYSCALL FreeMem
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
2019-09-20 15:15:06 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.CheckOpt ldy #1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
|
|
|
|
|
ldx #OptionVars-OptionList-1
|
|
|
|
|
|
|
|
|
|
.2 cmp OptionList,x
|
|
|
|
|
beq .3
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
.3 ldy OptionVars,x
|
|
|
|
|
lda #$ff
|
|
|
|
|
sta 0,y
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2019-04-17 15:31:18 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB USR/SRC/BIN/X.FILEENUM.S
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
2019-09-20 15:15:06 +00:00
|
|
|
|
OptionList .AS "CRMLWcrmlw"
|
2019-04-17 15:31:18 +00:00
|
|
|
|
OptionVars .DA #bContinue,#bRecurse,#bChar,#bLine,#bWord
|
|
|
|
|
.DA #bContinue,#bRecurse,#bChar,#bLine,#bWord
|
|
|
|
|
*--------------------------------------
|
2019-09-20 15:15:06 +00:00
|
|
|
|
MSG.USAGE .AS "Usage : WC File(s) (*,? wildcards allowed)\r\n"
|
2019-04-17 15:31:18 +00:00
|
|
|
|
.AS " -C : Continue on error\r\n"
|
|
|
|
|
.AS " -R : Recurse subdirectories\r\n"
|
|
|
|
|
.AS " -M : Print the CHAR counts\r\n"
|
|
|
|
|
.AS " -L : Print the LINE counts\r\n"
|
|
|
|
|
.AZ " -W : Print the WORD counts\r\n"
|
|
|
|
|
MSG.ERR .AZ "[%h]\r\n"
|
2019-09-20 15:15:06 +00:00
|
|
|
|
MSG.FILE .AZ "%10L %10L %10L %s\r\n"
|
|
|
|
|
MSG.TOTAL .AZ "%10L %10L %10L\r\n"
|
2019-04-17 15:31:18 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
|
|
|
|
ArgIndex .BS 1
|
|
|
|
|
|
|
|
|
|
bPrintTotal .BS 1
|
|
|
|
|
|
|
|
|
|
fCharCount .BS 4
|
|
|
|
|
fLineCount .BS 4
|
|
|
|
|
fWordCount .BS 4
|
|
|
|
|
|
|
|
|
|
tCharCount .BS 4
|
|
|
|
|
tLineCount .BS 4
|
|
|
|
|
tWordCount .BS 4
|
|
|
|
|
|
|
|
|
|
hSrcFullPath .BS 1
|
2019-09-20 15:15:06 +00:00
|
|
|
|
hFile .BS 1
|
|
|
|
|
hMem .BS 1
|
|
|
|
|
|
|
|
|
|
.INB USR/SRC/BIN/X.FILEENUM.G
|
2019-04-17 15:31:18 +00:00
|
|
|
|
|
|
|
|
|
DS.END
|
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE USR/SRC/BIN/WC.S
|
|
|
|
|
ASM
|