Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-12-07 14:20:04 +01:00
parent 6d7a794216
commit f162bd0bbe
2 changed files with 184 additions and 43 deletions

Binary file not shown.

View File

@ -3,10 +3,11 @@ NEW
.LIST OFF .LIST OFF
.OP 65C02 .OP 65C02
.OR $2000 .OR $2000
.TF BIN/WC .TF bin/wc
*-------------------------------------- *--------------------------------------
.INB INC/MACROS.I .INB INC/MACROS.I
.INB INC/A2OSX.I .INB INC/A2OSX.I
.INB INC/KERNEL.I
.INB INC/MLI.I .INB INC/MLI.I
.INB INC/MLI.E.I .INB INC/MLI.E.I
*-------------------------------------- *--------------------------------------
@ -59,9 +60,13 @@ CS.START cld
.DA CS.DOEVENT .DA CS.DOEVENT
.DA CS.QUIT .DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE L.MSG.USAGE .DA MSG.USAGE
L.MSG.FILE .DA MSG.FILE
L.MSG.ERR .DA MSG.ERR L.MSG.ERR .DA MSG.ERR
L.MSG.TOTAL .DA MSG.TOTAL L.MSG.FILE1 .DA MSG.FILE1
L.MSG.FILE2 .DA MSG.FILE2
L.MSG.FILE3 .DA MSG.FILE3
L.MSG.TOTAL1 .DA MSG.TOTAL1
L.MSG.TOTAL2 .DA MSG.TOTAL2
L.MSG.TOTAL3 .DA MSG.TOTAL3
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
CS.INIT clc CS.INIT clc
@ -69,29 +74,44 @@ CS.INIT clc
*-------------------------------------- *--------------------------------------
CS.RUN >INC.G ArgIndex CS.RUN >INC.G ArgIndex
>SYSCALL ArgV >SYSCALL ArgV
bcs .8 bcs .5
>STYA ZPPtr1 >STYA ZPPtr1
lda (ZPPtr1) lda (ZPPtr1)
cmp #'-' cmp #'-'
bne .4 bne .4
jsr CS.RUN.CheckOpt jsr CS.RUN.CheckOpt
bcc CS.RUN bcc CS.RUN
.9 >PUSHBI 0 .9 >PUSHBI 0
>LDYA L.MSG.USAGE >LDYA L.MSG.USAGE
>SYSCALL printf >SYSCALL printf
lda #E.SYN lda #E.SYN
sec sec
.99 rts rts
*-------------------------------------- *--------------------------------------
.4 >LDA.G hSrcBasePath .4 >LDA.G hSrcBasePath
bne .9 bne .9
>LDYA ZPPtr1 >LDYA ZPPtr1
jsr InitSrcDirYA jsr InitSrcDirYA
bcc CS.RUN bcc CS.RUN
rts .99 rts
.8 >LDA.G hSrcBasePath
beq .9 .5 >LDA.G hSrcBasePath
>LDYAI 256 bne .6
ldy #S.PS.hStdIn
lda (pPS),y
tax
lda OF.Table.hFD-1,x
>SYSCALL GetMemPtr
>STYA ZPPtr1
lda (ZPPtr1)
cmp #S.FD.T.PIPE
bne .9
jmp CS.RUN.PIPE
.6 >LDYAI 256
>SYSCALL getmem >SYSCALL getmem
bcs .99 bcs .99
>STYA ZPFullPath >STYA ZPFullPath
@ -101,10 +121,13 @@ CS.RUN >INC.G ArgIndex
>LDA.G hSrcBasePath >LDA.G hSrcBasePath
>SYSCALL GetMemPtr >SYSCALL GetMemPtr
>STYA ZPPtr1 >STYA ZPPtr1
ldy #$ff ldy #$ff
.80 iny .80 iny
lda (ZPPtr1),y lda (ZPPtr1),y
bne .80 bne .80
tya tya
clc clc
adc ZPFullPath adc ZPFullPath
@ -166,11 +189,31 @@ CS.RUN.LOOP ldy #S.PS.hStdIn
jsr BasePath.. jsr BasePath..
.8 jsr GetNextEntry .8 jsr GetNextEntry
jmp CS.RUN.LOOP jmp CS.RUN.LOOP
.90 jsr CS.RUN.PrintTstat .90 jsr CS.RUN.PrintTstat
lda #0 lda #0
sec sec
.99 rts .99 rts
*-------------------------------------- *--------------------------------------
CS.RUN.PIPE >LDYAI 256
>SYSCALL getmem
bcs .99
>STYA ZPLineBuf
txa
>STA.G hMem
ldy #S.PS.hStdIn
lda (pPS),y
>STA.G hFile
jsr CS.RUN.FILE.LOOP
jsr CS.RUN.PrintFstat
lda #0
sec
.99 rts
*--------------------------------------
CS.RUN.DIR lda bRecurse CS.RUN.DIR lda bRecurse
bpl .8 bpl .8
lda (ZPFileName) lda (ZPFileName)
@ -184,54 +227,37 @@ CS.RUN.DIR lda bRecurse
*-------------------------------------- *--------------------------------------
CS.RUN.DEV CS.RUN.DEV
.8 jsr GetNextEntry .8 jsr GetNextEntry
CS.RUN.DEV.CLC.RTS
clc clc
.9 rts rts
*-------------------------------------- *--------------------------------------
CS.RUN.FILE jsr FilterMatch CS.RUN.FILE jsr FilterMatch
bcs .8 no match, skip.... bcs CS.RUN.DEV.CLC.RTS no match, skip....
jsr CS.RUN.GetFilePath jsr CS.RUN.GetFilePath
jsr CS.RUN.OpenFile jsr CS.RUN.OpenFile
bcs .9 bcs .9
.1 >PUSHWI 256 jsr CS.RUN.FILE.LOOP
>PUSHW ZPLineBuf bcs .7
>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
.4 inc bInWord
.5 jsr CS.RUN.IncFChar
bra .2
.6 cmp #MLI.E.EOF
bne .7
jsr CS.RUN.CloseFile jsr CS.RUN.CloseFile
jsr CS.RUN.PrintFstat jsr CS.RUN.PrintFstat
bcs .99 bcs .99
jsr CS.RUN.AddFstat2Tstat jsr CS.RUN.AddFstat2Tstat
lda bTotal lda bTotal
bmi .8 bmi .8
beq .61 beq .61
lda #$fe lda #$fe
.61 inc .61 inc
sta bTotal sta bTotal
.8 clc .8 clc
rts rts
@ -242,6 +268,52 @@ CS.RUN.FILE jsr FilterMatch
.9 jmp CS.RUN.CheckErr .9 jmp CS.RUN.CheckErr
.99 rts .99 rts
*-------------------------------------- *--------------------------------------
CS.RUN.FILE.LOOP
.1 >PUSHWI 256
>PUSHW ZPLineBuf
>LDA.G hFile
>SYSCALL fgets
bcs .8
jsr CS.RUN.IncFLine
ldy #$ff
stz bInWord
.2 iny
lda (ZPLineBuf),y
bne .21
lda bInWord
beq .1
jsr CS.RUN.IncFWord
bra .1
.21 cmp #C.SPACE
beq .3
cmp #C.TAB
bne .4
.3 lda bInWord
beq .5
jsr CS.RUN.IncFWord
stz bInWord
bra .5
.4 inc bInWord
.5 jsr CS.RUN.IncFChar
bra .2
.8 cmp #MLI.E.EOF
bne .9
clc
rts
.9 sec
rts
*--------------------------------------
CS.RUN.CheckErr bcc .9 CS.RUN.CheckErr bcc .9
pha pha
>PUSHA >PUSHA
@ -329,24 +401,89 @@ CS.RUN.AddFstat2Tstat
*-------------------------------------- *--------------------------------------
CS.RUN.PrintFstat CS.RUN.PrintFstat
>PUSHW ZPRelPath >PUSHW ZPRelPath
ldx #0
bit bWord
bpl .1
>PUSHL.G fWordCount >PUSHL.G fWordCount
inx
.1 bit bLine
bpl .2
>PUSHL.G fLineCount
inx
.2 bit bChar
bpl .3
>PUSHL.G fCharCount
inx
.3 txa
beq .4
asl
tax
asl
* clc
adc #2
>PUSHA
>LDYA L.MSG.FILE1-2,x
>SYSCALL printf
rts
.4 >PUSHL.G fWordCount
>PUSHL.G fLineCount >PUSHL.G fLineCount
>PUSHL.G fCharCount >PUSHL.G fCharCount
>PUSHBI 14 >PUSHBI 14
>LDYA L.MSG.FILE >LDYA L.MSG.FILE3
>SYSCALL printf >SYSCALL printf
rts rts
*-------------------------------------- *--------------------------------------
CS.RUN.PrintTstat CS.RUN.PrintTstat
lda bTotal lda bTotal
bpl .8 bpl .8
ldx #0
bit bWord
bpl .1
>PUSHL.G tWordCount >PUSHL.G tWordCount
inx
.1 bit bLine
bpl .2
>PUSHL.G tLineCount
inx
.2 bit bChar
bpl .3
>PUSHL.G tCharCount
inx
.3 txa
beq .4
asl
tax
asl
>PUSHA
>LDYA L.MSG.TOTAL1-2,x
>SYSCALL printf
.8 rts
.4 >PUSHL.G tWordCount
>PUSHL.G tLineCount >PUSHL.G tLineCount
>PUSHL.G tCharCount >PUSHL.G tCharCount
>PUSHBI 12 >PUSHBI 12
>LDYA L.MSG.TOTAL >LDYA L.MSG.TOTAL3
>SYSCALL printf >SYSCALL printf
.8 rts rts
*-------------------------------------- *--------------------------------------
CS.DOEVENT sec CS.DOEVENT sec
rts rts
@ -398,8 +535,12 @@ MSG.USAGE .AS "Usage : WC File(s) (*,? wildcards allowed)\r\n"
.AS " -L : Print the LINE counts\r\n" .AS " -L : Print the LINE counts\r\n"
.AZ " -W : Print the WORD counts\r\n" .AZ " -W : Print the WORD counts\r\n"
MSG.ERR .AZ "[%h]\r\n" MSG.ERR .AZ "[%h]\r\n"
MSG.FILE .AZ "%10L %10L %10L %s\r\n" MSG.FILE3 .AS "%10L "
MSG.TOTAL .AZ "%10L %10L %10L\r\n" MSG.FILE2 .AS "%10L "
MSG.FILE1 .AZ "%10L %s\r\n"
MSG.TOTAL3 .AS "%10L "
MSG.TOTAL2 .AS "%10L "
MSG.TOTAL1 .AZ "%10L (total)\r\n"
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY
.OR 0 .OR 0