Kernel 0.93++

This commit is contained in:
Rémy GIBERT 2020-01-22 17:31:48 +01:00
parent f7234df2b6
commit 3a75661c7c
7 changed files with 485 additions and 9 deletions

Binary file not shown.

View File

@ -6,6 +6,7 @@ CSH.Q.CONST .EQ %10000000
CSH.Q.POINTER .EQ %00100000
CSH.Q.PPOINTER .EQ %01000000
CSH.Q.PPPOINTER .EQ %01100000
CSH.T.VOID .EQ 0
CSH.T.CHAR .EQ 1
CSH.T.INT .EQ 2
CSH.T.LONG .EQ 3
@ -84,6 +85,7 @@ CSH.KW >PSTR "if"
>PSTR "case"
>PSTR "break"
>PSTR "continue"
>PSTR "void"
>PSTR "float"
>PSTR "signed" char,int,long
>PSTR "unsigned" char,int,long
@ -114,6 +116,12 @@ CSH.FN >PSTR "printf"
>PSTR "getchar"
.DA #CSH.T.CHAR returned value
.DA #0
* void * malloc ( int size );
>PSTR "malloc"
.DA #CSH.Q.POINTER+CSH.T.VOID returned value
.DA #CSH.T.INT
.DA #0
*--------------------------------------
.DA #0
*--------------------------------------
MAN

View File

@ -49,6 +49,7 @@ J.CSH.KW .DA CSH.IF
.DA CSH.CASE
.DA CSH.BREAK
.DA CSH.CONTINUE
.DA CSH.VOID
.DA CSH.FLOAT
.DA CSH.SIGNED
.DA CSH.UNSIGNED
@ -67,6 +68,7 @@ J.CSH.EXEC .DA EXEC.printf
.DA EXEC.puts
.DA EXEC.cos
.DA EXEC.getchar
.DA EXEC.malloc
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CSH.R

View File

@ -237,6 +237,8 @@ CSH.UNSIGNED jsr CSH.GetChar
sec
rts
*--------------------------------------
CSH.VOID ldx #CSH.T.VOID
bra CSH.TYPE
CSH.CHAR ldx #CSH.T.CHAR
bra CSH.TYPE
CSH.UCHAR ldx #CSH.T.UCHAR
@ -257,10 +259,18 @@ CSH.TYPE stx ZPVarType
bcs .9
cmp #C.SPACE
bne .9
jsr CSH.GetNextCharNB
.11 jsr CSH.GetNextCharNB
bcs .9
jsr CSH.IsLetter
cmp #'*'
bne .10
lda #CSH.Q.POINTER
tsb ZPVarType
bra .11
.10 jsr CSH.IsLetter
bcs .9
jsr CSH.AddVar add with no value...
@ -1155,6 +1165,11 @@ EXEC.getchar >SYSCALL getchar
>PUSHA
rts
*--------------------------------------
EXEC.malloc >PULLYA
>SYSCALL getmem
>PUSHYA
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CSH.S.CORE
LOAD USR/SRC/BIN/CSH.S

View File

@ -77,6 +77,7 @@ CS.RUN >PUSHWI K.VER
>LDYA L.MSG.GREETINGS
>SYSCALL printf
bcs CS.INIT.RTS
jsr CS.RUN.ARGS
bcs CS.INIT.RTS
@ -102,6 +103,7 @@ CS.RUN >PUSHWI K.VER
pla
sec
rts
.8 lda #0 Exit Code = Success
sec
rts
@ -116,45 +118,55 @@ CS.RUN.ARGS inc ArgIndex
lda (ZPPtr1)
cmp #'-'
bne .4
ldy #1
lda (ZPPtr1),y
ldx #OptionVars-OptionList-1
.1 cmp OptionList,x
beq .2
dex
bpl .1
bra .90
.2 ldy OptionVars,x
lda #$ff
sta (pData),y
bra CS.RUN.ARGS
.4 >LDA.G hFileBuf
bne .90
>PUSHWZ Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY
>LDYA ZPPtr1
>SYSCALL LoadTxtFile
bcs .9
txa
>STA.G hFileBuf
>SYSCALL GetMemPtr
>STYA ZPFileBuf
>STYA ZPFileBufPtr
bra CS.RUN.ARGS
.7 >LDA.G hFileBuf
beq .90
clc
rts
.9 rts
.90 >PUSHBI 0
>LDYA L.MSG.USAGE
>SYSCALL printf
lda #E.SYN
sec QUIT Process
.9 rts
rts
*--------------------------------------
CS.DOEVENT sec
rts

View File

@ -270,7 +270,14 @@ CharIn tax
lda (pData) #EscBuffer
inc
sta (pData)
tay
cmp #32
bne .10
>DEBUG
>STZ.G bEscMode
clc
rts
.10 tay
txa
sta (pData),y
@ -339,7 +346,7 @@ CharIn.Esc >STZ.G bEscMode
.3 stz TmpByte
ldy #EscBuffer+1
ldy #1
.4 lda (pData),y
cmp #';'
@ -401,7 +408,7 @@ CharIn.Esc >STZ.G bEscMode
bra .6
.7 lda TmpByte
>STA.G ScreenW
>STA.G ScreenW
sec
rts
@ -596,7 +603,7 @@ DLG.FIND.LEN .EQ *-DLG.FIND
.DUMMY
.OR 0
DS.START
EscBuffer .BS 16
EscBuffer .BS 33
bEscMode .BS 1
bExit .BS 1

432
SYS/KERNEL.S.ENVX.txt Normal file
View File

@ -0,0 +1,432 @@
NEW
AUTO 3,1
*--------------------------------------
ENVX.PutEnv ldy #$ff
.1 iny
lda (TXTPTR),y NAME=
beq .9
cmp #'='
bne .1
tya
sec skip =
adc TXTPTR
sta FORPNT
lda #0
adc TXTPTR+1
sta FORPNT+1
bra K.SetEnv.I
.9 lda #E.SYN
sec
rts
*--------------------------------------
ENVX.SetEnv jsr ENVX.UnsetEnv
.1 jsr ENV.InitEnvP3 ZPPtr3 -> Env (SETREADAUX)
lda #1
sta ZPPtr4
stz ZPPtr4+1 ZPPtr4 = ENVSIZE = 1
.10 lda (ZPPtr3) End of ENV
beq .15
jsr ENV.GetP3LenY
jsr ENV.NextEnvP3Y
jsr ENV.NextEnvP4Y
bra .10
.15 .DO AUXENV=1
sta CLRREADAUX
.FIN
ldy #$ff
.16 iny
lda (TXTPTR),y
beq .17
jsr SHARED.IsIDValid
bcc .16
.17 jsr ENV.NextEnvP4Y ZPPtr4 = ENVSIZE + VAR
ldy #$ff
.19 iny
lda (FORPNT),y
bne .19
jsr ENV.NextEnvP4Y ZPPtr4 = ENVSIZE + VALUE
lda ZPPtr4
beq .20
inc ZPPtr4+1
.20 ldy #S.PS.ENVPAGECNT
lda (pPs),y
cmp ZPPtr4+1
bcs .22 env is large enough
lda ZPPtr4+1
jsr ENV.Dup.A
bcs .9
pha
ldy #S.PS.hENV
lda (pPs),y
.DO AUXENV=1
ldx #SYS.FreeStkObj
jsr K.SYSCALL2.AUX
.ELSE
jsr K.Freemem
.FIN
pla
ldy #S.PS.hENV
sta (pPs),y
txa
dey S.PS.ENVPAGECNT
sta (pPs),y
bra .1 Start over
.22 ldy #$ff
.DO AUXENV=1
sta SETWRITEAUX
.FIN
.23 iny
lda (TXTPTR),y
sta (ZPPtr3),y
beq .24
jsr SHARED.IsIDValid
bcc .23
.24 lda #'='
sta (ZPPtr3),y
jsr ENV.NextEnvP3Y
ldy #$ff
.25 iny
lda (FORPNT),y
sta (ZPPtr3),y
bne .25
iny
sta (ZPPtr3),y don't forget array ending 0
clc
.9 .DO AUXENV=1
sta CLRREADAUX
sta CLRWRITEAUX
.FIN
rts
*--------------------------------------
ENVX.GetEnv lda TXTPTR
beq K.GetEnvDump
jsr ENV.FindVar
bcs .9
jsr ENV.NextEnvP3Y Skip NAME=
lda FORPNT+1
bne .3
ldy #$ff
.DO AUXENV=1
sta SETREADAUX
.FIN
.1 iny
lda (ZPPtr3),y
bne .1
.DO AUXENV=1
sta CLRREADAUX
.FIN
iny
bne .2
inc
.2 .DO AUXENV=1
sta CLRREADAUX
sta CLRWRITEAUX
.FIN
jsr K.getmem
bcs .99
>STYA FORPNT
.3 .DO AUXENV=1
sta SETREADAUX
.FIN
ldy #$ff
.4 iny
lda (ZPPtr3),y
sta (FORPNT),y
bne .4
>LDYA FORPNT
.DO AUXENV=1
sta CLRREADAUX
.FIN
clc
rts
.9 >LDYAI 0
* sec
.99 rts
K.GetEnvDump ldy #S.PS.ENVPAGECNT
lda (pPs),y
sta .1+1
ldy #0
jsr K.getmem
bcs .9
>STYA FORPNT
sty .80+1
sta .81+1
stx .82+1
jsr ENV.InitEnvP3 SETREADAUX
.1 ldx #$ff SELF MODIFIED
ldy #0
.2 lda (ZPPtr3),y
sta (FORPNT),y
iny
bne .2
.80 ldy #$ff SELF MODIFIED
.81 lda #$ff SELF MODIFIED
.82 ldx #$ff SELF MODIFIED
.DO AUXENV=1
sta CLRREADAUX
.FIN
clc
.9 rts
*--------------------------------------
ENVX.UnsetEnv jsr ENV.FindVar
bcs . 8 not found, quit
jsr ENV.DelVarP3 Ptr3 -> NAME=VALUE
clc
rts
*--------------------------------------
* ENV.FindVar
* In:
* TXTPTR -> NAME
* Out:
* CC: Found
* Y = NAME len
* TXTPTR -> NAME
* ZPPtr3 -> NAME=VALUE
* CS: Not Found
* TXTPTR -> NAME
* ZPPtr3 -> PTR to Ending 0
*--------------------------------------
ENVX.FindVar
.DO AUXENV=1
sta SETREADAUX
sta SETWRITEAUX
.FIN
jsr ENV.InitEnvP3 Store ENV
.1 lda (ZPPtr3)
beq .9 end of ENV
ldy #$ff
.2 iny
.DO AUXENV=1
jsr SHARED.TXTPTR.GetY
.ELSE
lda (TXTPTR),y
.FIN
beq .3
jsr SHARED.IsIDValid
bcs .3
cmp (ZPPtr3),y
beq .2
bra .4
.3 lda (ZPPtr3),y
cmp #'='
bne .4
.DO AUXENV=1
sta CLRREADAUX
sta CLRWRITEAUX
.FIN
clc
rts
.4 jsr ENV.NextEnvP3 Skip NAME=VALUE
bra .1
.9 .DO AUXENV=1
sta CLRREADAUX
sta CLRWRITEAUX
.FIN
sec
rts
*--------------------------------------
* ENV.DelVarP3
* In:
* ZPPtr3 -> ENV.NAME to Discard
*--------------------------------------
ENV.DelVarP3 .DO AUXENV=1
sta SETREADAUX
sta SETWRITEAUX
.FIN
>LDYA ZPPtr3 save actual Ptr
>STYA ZPPtr4
jsr ENV.NextEnvP3 Skip NAME=VALUE
.1 ldy #$ff
.2 iny
lda (ZPPtr3),y Move back CSTRs...
sta (ZPPtr4),y
bne .2
tya
beq .8 we moved back ending \0
jsr ENV.NextEnvP3Y
jsr ENV.NextEnvP4Y
bra .1
.8 .DO AUXENV=1
sta CLRREADAUX
sta CLRWRITEAUX
.FIN
rts
*--------------------------------------
ENV.InitEnvP3 .DO AUXENV=1
sta CLRREADAUX
.FIN
ldy #S.PS.hENV
lda (pPs),y
.DO AUXENV=1
sta SETREADAUX
.FIN
jsr K.GetMemPtr
>STYA ZPPtr3 Store ENV
rts
*--------------------------------------
ENV.NextEnvP3 jsr ENV.GetP3LenY
*--------------------------------------
ENV.NextEnvP3Y tya
ENV.NextEnvP3A sec
adc ZPPtr3
sta ZPPtr3
bcc .8
inc ZPPtr3+1
.8 rts
*--------------------------------------
ENV.GetP3LenY ldy #$ff
.1 iny
lda (ZPPtr3),y
bne .1
rts
*--------------------------------------
ENV.NextEnvP4Y tya
sec
adc ZPPtr4
sta ZPPtr4
bcc .8
inc ZPPtr4+1
.8 rts
*--------------------------------------
* ENV.Dup
* In:
* A = ENV hMem To Duplicate
* Out:
* A = hMem to new ENV
* X = Page Count
*--------------------------------------
ENV.Dup ldy #S.PS.ENVPAGECNT
lda (pPs),y
ENV.Dup.A sta .8+1 Store target page Count
ldy #S.PS.ENVPAGECNT get SOURCE page count
lda (pPs),y
sta .10+1
ldy #S.PS.hENV
lda (pPs),y
.DO AUXENV=1
sta SETREADAUX
sta SETWRITEAUX
.FIN
jsr K.GetMemPtr
>STYA .1+1
ldy #0
lda .8+1
jsr K.GetMem
bcs .9
>STYA .2+1 Target Buffer
phx save hMem
jsr Mem.SetOwner Set Ownership
ldy #0
.10 ldx #$ff SELF MODIFIED
.1 lda $ffff,y SELF MODIFIED
.2 sta $ffff,y SELF MODIFIED
iny
bne .1
inc .1+2
inc .2+2
dex
bne .1
.8 ldx #$ff SELF MODIFIED Target Page Count
pla hMem
clc
.9 .DO AUXENV=1
sta CLRREADAUX
sta CLRWRITEAUX
.FIN
rts
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.ENVX
LOAD USR/SRC/SYS/KERNEL.S
ASM