Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-10-26 16:33:37 +02:00
parent 9be1af0109
commit 12ad776ef6
9 changed files with 179 additions and 172 deletions

Binary file not shown.

Binary file not shown.

View File

@ -24,8 +24,8 @@ FieldNum .BS 1
StartChar .BS 1
EndChar .BS 1
Separator .BS 1
ZS.END
.ED
hToClose .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -145,6 +145,10 @@ CS.RUN stz ArgCount
lda (ZPPtr1)
cmp #S.FD.T.PIPE
bne .97
ldy #S.PS.hStdIn
lda (pPS),y
sta hToClose
*--------------------------------------
CS.RUN.LOOP >SLEEP
@ -160,8 +164,7 @@ CS.RUN.LOOP >SLEEP
beq CS.RUN.LOOP
jsr CS.RUN.OUT
bcs .9
bra CS.RUN.LOOP
bcc CS.RUN.LOOP
.8 cmp #MLI.E.EOF
bne .90
@ -200,8 +203,10 @@ CS.RUN.OUT ldx FieldNum
.6 iny
lda (ZPBufPtr),y
beq .8
eor Separator
bne .6
sta (ZPBufPtr),y
.8 >LDYA ZPBufPtr
@ -264,7 +269,12 @@ CS.RUN.AddYToBufPtr
lda ZPBufPtr+1
.8 rts
*--------------------------------------
CS.QUIT lda hBuf
CS.QUIT lda hToClose
beq .1
>SYSCALL fclose Close the pipe
.1 lda hBuf
beq .8
>SYSCALL FreeMem

View File

@ -109,6 +109,7 @@ CS.RUN stz ArgIndex
.8 lda hFile
bne .80
ldy #S.PS.hStdIn
lda (pPS),y
tax
@ -119,6 +120,10 @@ CS.RUN stz ArgIndex
cmp #S.FD.T.PIPE
bne .97
ldy #S.PS.hStdIn
lda (pPS),y
sta hFile
.80 >LDYAI 256
>SYSCALL GetMem
bcs .9
@ -130,12 +135,9 @@ CS.RUN.LOOP >SLEEP
>PUSHWI 256
>PUSHW ZPBufPtr
lda hFile
bne .1
ldy #S.PS.hStdIn
lda (pPS),y
.1 >SYSCALL fgets
lda hFile
>SYSCALL fgets
bcs .9
inc LineNum
bne .2
@ -219,16 +221,16 @@ CS.RUN.toUpper bit bIgnoreCase
.9 rts
*--------------------------------------
CS.QUIT lda hBuf
CS.QUIT lda hFILE
beq .1
>SYSCALL FClose
.1 lda hBuf
beq .8
>SYSCALL FreeMem
.1 lda hFILE
beq .2
>SYSCALL FClose
.2
.8 clc
rts
*--------------------------------------
@ -250,8 +252,7 @@ MSG.NUMLINE .AZ "%5D:"
.DUMMY
.OR 0
DS.START
DS.END
.ED
DS.END .ED
*--------------------------------------
MAN
SAVE USR/SRC/BIN/GREP.S

View File

@ -279,21 +279,21 @@ CMD.SET.EXEC jsr CORE.ArgV.NextChar skip "`"
jmp CMD.READ.VAR
.9 rts
*--------------------------------------
CMD.DATE sec
.HS 90 BCC
CMD.TIME clc
php
>LEA.G TimeBuf
CMD.DATE >LEA.G TimeBuf
>SYSCALL Time
>PUSHEA.G TimeBuf
plp
bcc .1
>PUSHW L.FMT.DATE
bra .2
.1 >PUSHW L.FMT.TIME
.2 >LEA.G StatBuf
lda (ZPArgVBufPtr)
beq .1
>LDYA ZPArgVBufPtr
bra .2
.1 >LDYA L.FMT.DATE
.2 >PUSHYA
>LEA.G StatBuf
>SYSCALL StrFTime
>LEA.G StatBuf
>SYSCALL puts
@ -338,49 +338,8 @@ CMD.ECHO stz ZPPtr1 echo -N
CMD.ECHO.CSYN lda #E.CSYN
sec
rts
*--------------------------------------
CMD.GETKEY lda (ZPArgVBufPtr)
beq CMD.ECHO.CSYN
ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL feof
bcs .9
tay
beq .1
.10 lda #'0'
>STA.G M32.BUF
iny
lda #0
sta (pData),y
bra .8
.1 >SYSCALL getchar
bcs .9
cmp #'['
bne .4
>SYSCALL getchar
bcs .9
ldx #EscChars.Cnt-1
.2 cmp EscChars,x
beq .3
dex
bpl .2
bra .10
.3 lda EscChars.Remap,x
.4 >PUSHA
>PUSHBI 1
>PUSHW L.FMT.GETKEY
>LEA.G M32.BUF
>SYSCALL sprintf
bcs .9
.8 >PUSHEA.G M32.BUF
>LDYA ZPArgVBufPtr
>SYSCALL SetEnv
.9
CMD.GETKEY.RTS rts
CMD.ECHO.RTS rts
*--------------------------------------
CMD.READ lda (ZPArgVBufPtr)
beq .9
@ -404,7 +363,7 @@ CMD.READ lda (ZPArgVBufPtr)
>PUSHBI 0
>LDYA ZPArgVBufPtr
>SYSCALL printf
bcs CMD.GETKEY.RTS
bcs CMD.ECHO.RTS
bra .5
.9 jmp CMD.E.CSYN
@ -414,7 +373,7 @@ CMD.READ lda (ZPArgVBufPtr)
beq .9
>LDYA ZPArgVBufPtr
>SYSCALL AToL
bcs CMD.GETKEY.RTS
bcs CMD.ECHO.RTS
>PULLA
>STA.G READ.N

View File

@ -107,35 +107,34 @@ CORE.Run.SYN lda #E.SYN
sec
rts
*--------------------------------------
CORE.Run >LDYA ZPInputBufPtr Save Actual cmd for looping
CORE.Run jsr IO.Reset
clc
.HS B0 BCS
CORE.Run.1 sec coming from PIPE OUT
ror
>STA.G CORE.bPipeIn
>LDYA ZPInputBufPtr Save Actual cmd for looping
>STYA ZPInputCmdPtr
>LDYA ZPArgVBuf
>STYA ZPArgVBufPtr
lda #0 Reset ArgV Buffer
sta (ZPArgVBuf)
lda #S.PS.F.HOLD
sta CORE.PSFlags
lda #$ff
dec
* lda #$ff
sta CORE.IntCmd assume external
jsr CORE.GetCharNB
lda #S.PS.F.HOLD
sta CORE.PSFlags
.3 jsr CORE.GetCharNB
bcs CORE.Run.EOF
cmp #'|'
bne .21
jsr IO.Pipe.In
bcs .9
jsr CORE.GetNextCharNB Skip |
bcs CORE.Run.SYN
bra .3
.21 pha
jsr IO.Reset
pla
.3 cmp #C.CR empty line ?
cmp #C.CR empty line ?
bne .33
jsr CORE.GetNextChar skip CR...
bra .8
@ -145,8 +144,7 @@ CORE.Run >LDYA ZPInputBufPtr Save Actual cmd for looping
.12 jsr CORE.SkipLine
.8 jsr IO.Reset
lda #0
.8 lda #0
clc
.9 rts EOL, CS,A=0
@ -197,36 +195,64 @@ CORE.Run.5 >LDYA L.CORE.IO
CORE.Run.6 jsr CORE.ArgV.Add
CORE.Run.7 jsr CORE.GetCharNB
bcs CORE.ExecCmd.1 Nothing to skip
bcs .2 Nothing to skip
jsr CORE.IsEndCmd
bcs CORE.Run.5
cmp #'|'
bne CORE.ExecCmd skip CR, ;
tax
jsr CORE.GetNextCharNB Skip EoL char
cpx #'|' Pipe OUT ?
bne .2
sec
.1 .HS 90 BCC
.2 clc
ror
>STA.G CORE.bPipeOut
>LDA.G CORE.bPipeIn
bpl .3
jsr IO.Pipe.In
bcs CORE.Run.RTS
.3 >LDA.G CORE.bPipeOut
bpl CORE.ExecCmd
jsr IO.Pipe.Out
bcs CORE.Run.RTS
lda CORE.PSFlags
and #$ff^S.PS.F.HOLD Run in the background...
ora #S.PS.F.CLOSEONX ...and close PIPE on exit
sta CORE.PSFlags
jsr CORE.ExecCmd.1 Do not skip |
lda #S.PS.F.HOLD Run in the background...
trb CORE.PSFlags
lda #S.PS.F.CLOSEONX ...and close PIPE OUT on exit
tsb CORE.PSFlags
jsr CORE.ExecCmd
php
pha
jsr IO.Pop.Out restore Output
>LDA.G CORE.bPipeIn
bpl .4
jsr IO.Pop.In restore Input
.4 jsr IO.Pop.Out restore Output
pla
plp
bcs CORE.Run.RTS
jmp CORE.Run.1 Loop with Pipe IN
CORE.Run.RTS rts
*--------------------------------------
* Input : ZPArgVBuf
*--------------------------------------
CORE.ExecCmd jsr CORE.GetNextCharNB Skip EoL char
CORE.ExecCmd.1 lda #0
CORE.ExecCmd lda #0
sta (ZPArgVBufPtr)
>LDYA ZPArgVBuf
>STYA ZPArgVBufPtr
@ -252,10 +278,7 @@ CORE.ExecExtCmd >PUSHB CORE.PSFlags
>PUSHA
>PUSHBI 1
>PUSHW L.MSG.PID
ldy #S.PS.hStdErr
lda (pPS),y
>SYSCALL fprintf
rts
jmp IO.PrintErr
.4 >SLEEP Suspend this PID
sec

View File

@ -48,13 +48,8 @@ IO.Reset.In sec
beq .8
bcc .1
pha
ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL fclose
pla
jsr IO.Close.Y
.1 ldy #S.PS.hStdIn
sta (pPS),y
@ -102,11 +97,8 @@ IO.Reset.Out sec
bcc .1
pha
ldy #S.PS.hStdOut
lda (pPS),y
>SYSCALL fclose
pla
jsr IO.Close.Y
.1 ldy #S.PS.hStdOut
sta (pPS),y
@ -125,16 +117,21 @@ IO.Set.Err pha
*--------------------------------------
IO.Reset.Err >LDA.G IO.hErr
beq .8
pha
ldy #S.PS.hStdErr
lda (pPS),y
>SYSCALL fclose
pla
jsr IO.Close.Y
ldy #S.PS.hStdErr
sta (pPS),y
>STZ.G IO.hErr
.8 rts
*--------------------------------------
IO.Close.Y pha
lda (pPS),y
>SYSCALL fclose
pla
rts
*--------------------------------------
IO.Pipe.OpenR ldx #O.RDONLY+O.TEXT
.HS 2C BIT ABS

View File

@ -16,36 +16,34 @@ C.NOHUP .EQ 3
C.DATE .EQ 4
C.ECHO .EQ 5
C.EXIT .EQ 6
C.GETKEY .EQ 7
C.MD .EQ 8
C.PAUSE .EQ 9
C.PWD .EQ 10
C.RD .EQ 11
C.READ .EQ 12
C.REN .EQ 13
C.SET .EQ 14
C.SLEEP .EQ 15
C.SHIFT .EQ 16
C.TIME .EQ 17
C.PUSHD .EQ 18
C.POPD .EQ 19
C.FUNCTION .EQ 20
C.CALL .EQ 21
C.BREAK .EQ 22
C.SWITCH .EQ 23
C.CASE .EQ 24
C.DEFAULT .EQ 25
C.MD .EQ 7
C.PAUSE .EQ 8
C.PWD .EQ 9
C.RD .EQ 10
C.READ .EQ 11
C.REN .EQ 12
C.SET .EQ 13
C.SLEEP .EQ 14
C.SHIFT .EQ 15
C.PUSHD .EQ 16
C.POPD .EQ 17
C.FUNCTION .EQ 18
C.CALL .EQ 19
C.BREAK .EQ 20
C.SWITCH .EQ 21
C.CASE .EQ 22
C.DEFAULT .EQ 23
*--------------------------------------
C.FOR .EQ 26
C.FOR .EQ 24
C.FOR.LIST .EQ 0
C.FOR.FILEEXEC .EQ 1
C.WHILE .EQ 27
C.IF .EQ 28
C.NEXT .EQ 29
C.LOOP .EQ 30
C.ELSE .EQ 31
C.FI .EQ 32
C.END .EQ 33
C.WHILE .EQ 25
C.IF .EQ 26
C.NEXT .EQ 27
C.LOOP .EQ 20
C.ELSE .EQ 29
C.FI .EQ 30
C.END .EQ 31
*--------------------------------------
C.CLEXEC .EQ 63
*--------------------------------------
@ -124,8 +122,6 @@ L.MSG.ERROR .DA MSG.ERROR
L.MSG.PRINTENV .DA MSG.PRINTENV
L.MSG.PID .DA MSG.PID
L.FMT.DATE .DA FMT.DATE
L.FMT.TIME .DA FMT.TIME
L.FMT.GETKEY .DA FMT.GETKEY
L.FMT.Long .DA FMT.Long
J.ESC .DA CL.BS left arrow
.DA HIS.GetNext
@ -141,7 +137,6 @@ J.CMD .DA CMD...
.DA CMD.DATE
.DA CMD.ECHO
.DA CMD.EXIT
.DA CMD.GETKEY
.DA CMD.MD
.DA CMD.PAUSE
.DA CMD.PWD
@ -151,7 +146,6 @@ J.CMD .DA CMD...
.DA CMD.SET
.DA CMD.SLEEP
.DA CMD.SHIFT
.DA CMD.TIME
.DA CMD.PUSHD
.DA CMD.POPD
.DA CMD.FUNCTION
@ -530,9 +524,7 @@ MSG.ERROR .AS "[$%h]:%S."
MSG.ECHOCRLF .AZ "\r\n"
MSG.PRINTENV .AZ "%s = %s\r\n"
MSG.PID .AZ "PID=%d\r\n"
FMT.DATE .AZ "%A (%w), %B %d %Y"
FMT.TIME .AZ "%H:%M:%S (%I:%M:%S%p)"
FMT.GETKEY .AZ "%d"
FMT.DATE .AZ "%A, %B %d %Y %H:%M:%S"
FMT.Long .AZ "%L"
*--------------------------------------
HOME.PROFILE .AZ "${HOME}PROFILE"
@ -555,7 +547,6 @@ CMD .AT ".."
.AT "DATE"
.AT "ECHO"
.AT "EXIT"
.AT "GETKEY"
.AT "MD"
.AT "PAUSE"
.AT "PWD"
@ -565,7 +556,6 @@ CMD .AT ".."
.AT "SET"
.AT "SLEEP"
.AT "SHIFT"
.AT "TIME"
.AT "PUSHD"
.AT "POPD"
.AT "FUNCTION"
@ -673,6 +663,8 @@ CL.Len .BS 1
CL.bReady .BS 1
CORE.hArgVBuf .BS 1
CORE.bPipeIn .BS 1
CORE.bPipeOut .BS 1
HIS.hBuf .BS 1
HIS.Count .BS 1

View File

@ -39,8 +39,10 @@ K.PTime2Time jsr SHARED.SPtr1PPtr2
lsr C is high bit of month
ldy #S.Time.YEAR
sta (ZPPtr2),y set year
sta ACC32+3 for conputing Century/WDAY later
lda (ZPPtr1) Get Month/day
pha save Day
ror
lsr
@ -53,6 +55,7 @@ K.PTime2Time jsr SHARED.SPtr1PPtr2
and #$1F
iny
sta (ZPPtr2),y set day
lda ACC32+3 get back year
cmp #69 if before 70 CC,if > 70, CS
lda #0
@ -60,7 +63,7 @@ K.PTime2Time jsr SHARED.SPtr1PPtr2
eor #1 toggle C
adc #19 set date before 1970 -> 20xx
sta (ZPPtr2) set Century
sta ACC32+2 for conputing WDAY later
sta ACC32+2 for computing WDAY later
ldy #2
lda (ZPPtr1),y Get Min
@ -80,22 +83,28 @@ K.PTime2Time jsr SHARED.SPtr1PPtr2
*--------------------------------------
K.ComputeWDAY lda #DAY0-1 Thursday : 4 (-1 for mod 7)
pha
lda #19
lda #CENTURY0
sta ACC32
lda #70
lda #YEAR0
sta ACC32+1
.1 ldy ACC32
lda ACC32+1
cpy ACC32+2
bne .2
cmp ACC32+3
beq .4
.2 jsr TIME.IsLeapYearYA CS = Leap
pla
adc #1
adc #1 365 mod 7
cmp #7
bcc .3
sbc #7 MOD 7
.3 pha
inc ACC32+1
lda ACC32+1
@ -109,28 +118,41 @@ K.ComputeWDAY lda #DAY0-1 Thursday : 4 (-1 for mod 7)
.4 ldy #S.Time.MONTH
lda (ZPPtr2),y get month
tax
.5 lda K.StrFTime.MDAY-1,x get day count in this month
clc
dex don't include actual month
beq .71
.5 clc assume NO leap
lda K.StrFTime.MDAY-1,x get day count in this month
bne .6 february ?
ldy ACC32+2
lda ACC32+3
jsr TIME.IsLeapYearYA CS = Leap
.6 pla
adc K.StrFTime.MDAY-1,x
cmp #7
bcc .7
sbc #7
.7 pha
dex
bne .5
pla
.71 pla
ldy #S.Time.DAY
clc
adc (ZPPtr2),y get day in month (1..31)
dec adjust range 0.30 for MOD 7
.8 cmp #7 MOD 7
bcc .80
sbc #7
bra .8
.80 inc adjust range 1..7
ldy #S.Time.WDAY
sta (ZPPtr2),y
@ -256,14 +278,17 @@ K.CTime2Time.HMS
TIME.IsLeapYearYA
cmp #0 Year = 00 ?
bne .1 no
tya year = 00, get century in a
and #$3 mod 4 = 0 ?
beq .9 leap year
.8 clc not leap
tya year = 00, get century in A
and #$3 Century mod 4 = 0 ?
beq .9 leap year (2000)
.8 clc not leap (1900)
rts
.1 and #$3 mod 4 = 0 ?
bne .8
.9 sec Leap
rts
*--------------------------------------