Kernel 0.94

This commit is contained in:
Rémy GIBERT 2020-07-31 16:46:11 +02:00
parent 4ca0e321ad
commit 6ad471abcc
10 changed files with 173 additions and 149 deletions

Binary file not shown.

View File

@ -25,6 +25,6 @@ CSH.StackPtr .BS 1
CSH.VarDef .BS 6
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CSH.D
LOAD USR/SRC/BIN/CSH.S
SAVE usr/src/bin/csh.d
LOAD usr/src/bin/csh.s
ASM

View File

@ -18,6 +18,6 @@ CSH.E.OOM .EQ $D2
CSH.E.DUP .EQ $D3
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CSH.E
LOAD USR/SRC/BIN/CSH.S
SAVE usr/src/bin/csh.e
LOAD usr/src/bin/csh.s
ASM

View File

@ -77,6 +77,7 @@ CSH.BOPS >PSTR "+"
* Reserved Directives:
*--------------------------------------
CSH.DIRS >PSTR "define"
>PSTR "include"
.HS 00
*--------------------------------------
* Reserved Keywords:
@ -192,6 +193,6 @@ CSH.FN
.DA #0
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CSH.I
LOAD USR/SRC/BIN/CSH.S
SAVE usr/src/bin/csh.i
LOAD usr/src/bin/csh.s
ASM

View File

@ -50,6 +50,7 @@ L.CSH.DIRS .DA CSH.DIRS
L.CSH.KW .DA CSH.KW
L.CSH.STYPES .DA CSH.STYPES
J.CSH.DIRS .DA CSH.DIR.DEFINE
.DA CSH.DIR.INCLUDE
J.CSH.KW .DA CSH.IF
.DA CSH.WHILE
.DA CSH.ELSE
@ -96,6 +97,6 @@ J.CSH.EXEC .DA EXEC.log
.DA EXEC.malloc
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CSH.R
LOAD USR/SRC/BIN/CSH.S
SAVE usr/src/bin/csh.r
LOAD usr/src/bin/csh.s
ASM

View File

@ -1,6 +1,6 @@
NEW
AUTO 3,1
.LIST OFF
.LIST OFF
*--------------------------------------
CSH.Init >SYSCALL SListNew
bcs .9
@ -11,12 +11,12 @@ CSH.Init >SYSCALL SListNew
bcs .9
>STA.G CSH.hTags
>SYSCALL SListNew
bcs .9
>STA.G CSH.hSymbols
>LDYAI 256
>SYSCALL GetMem
bcs .9
@ -54,25 +54,25 @@ CSH.Init >SYSCALL SListNew
*--------------------------------------
CSH.Quit >LDA.G CSH.hSymbols
beq .1
>PUSHA
>SYSCALL SListFree
.1 >LDA.G CSH.hTags
beq .2
>PUSHA
>SYSCALL SListFree
.2 >LDA.G CSH.hDefines
beq .3
>PUSHA
>SYSCALL SListFree
.3 lda ZPhMacro
jsr .7
>LDA.G hFileBuf
jsr .7
@ -83,7 +83,7 @@ CSH.Quit >LDA.G CSH.hSymbols
jsr .7
>LDA.G CSH.hConst
.7 beq CSH.Quit.RTS
>SYSCALL FreeMem
CSH.Quit.RTS rts
@ -93,7 +93,7 @@ CSH.Run jsr CSH.GetCharNB
CSH.Run.1 cmp #C.CR empty line....
beq .2
cmp #'/'
bne .3 comments ...
@ -139,7 +139,7 @@ CSH.Run.1 cmp #C.CR empty line....
>STYA ZPVarID
jsr CSH.GetVarDef Get Type & ptr...
bcs .9
jsr CSH.GetCharNB
bcs .9
@ -180,7 +180,7 @@ CSH.Run.1 cmp #C.CR empty line....
beq .80
jmp CSH.Run.1
.80 jmp CSH.GetNextChar Skip CR
*--------------------------------------
CSH.COMMENTS jsr CSH.GetNextChar
@ -188,74 +188,100 @@ CSH.COMMENTS jsr CSH.GetNextChar
bne .90
jmp CSH.SkipLine skip line.....
.90 lda #CSH.E.SYNTAX
sec
rts
*--------------------------------------
CSH.DIR jsr CSH.GetNextCharNB
bcs .99
cmp #'!' #!/bin/csh
bne .1
bra CSH.SkipLine
jmp CSH.SkipLine
.1 >LDYA L.CSH.DIRS
jsr CSH.LookupID
bcs .91
jmp (J.CSH.DIRS,x)
.91 lda #CSH.E.INVDIR
sec
.99 rts
*--------------------------------------
CSH.DIR.DEFINE jsr CSH.CheckSpace
bcs .99
jsr CSH.IsLetter
bcs .90
>LDA.G CSH.hDefines
jsr CSH.NewKey
bcs .99
>STYA ZPVarID
jsr CSH.CheckSpace
bcs .99
ldy #$ff
.1 iny
lda (ZPFileBufPtr),y
beq .2
cmp #C.CR
bne .1
dey
.2 iny
lda #0
pha
phy
>PUSHB.G CSH.hDefines
>PUSHW ZPVarID
>PUSHW ZPFileBufPtr
ply
pla
>PUSHYA DataLen
>SYSCALL SListAddData
bcs .99
bra CSH.SkipLine
.90 lda #CSH.E.SYNTAX
sec
.99 rts
*--------------------------------------
CSH.DIR.INCLUDE jsr CSH.CheckSpace
bcs .99
cmp #'"'
beq .1
cmp #'<'
bne .80
lda #'>'
.1 sta ArgIndex
bra CSH.SkipLine
.90 lda #CSH.E.SYNTAX
sec
.99 rts
@ -270,7 +296,7 @@ CSH.SkipLine jsr CSH.GetNextChar
*--------------------------------------
* Built in Keywords
*--------------------------------------
CSH.KW.JMP txa
CSH.KW.JMP txa
>STA.G CSH.CmdSave
jmp (J.CSH.KW,x)
*--------------------------------------
@ -295,7 +321,7 @@ CSH.IF jsr CSH.GetCharNB
bne .9
jsr CSH.GetNextCharNB Skip '{'
bcs .99
jsr CSH.IsValue0 X = var type from ExpEval
bcc .6 Value=0, skip {{....}}
@ -306,14 +332,14 @@ CSH.IF jsr CSH.GetCharNB
>LDA.G CSH.BufPtrSave+1 WHILE : push loop address...
jsr CSH.Push
>LDA.G CSH.BufPtrSave
jsr CSH.Push
jsr CSH.Push
pla
.1 jsr CSH.Push
bcs .99
lda #'}' Tell '}' is expected at the end of block
jsr CSH.Push
bcs .99
rts
.6 jsr CSH.SkipBlock
@ -333,7 +359,7 @@ CSH.IF jsr CSH.GetCharNB
* >LDA.G CSH.BufPtrSave+1 WHILE : push loop address...
* jsr CSH.Push
* >LDA.G CSH.BufPtrSave
* jsr CSH.Push
* jsr CSH.Push
* pla
* jmp CSH.Push Push "WHILE" Token
*--------------------------------------
@ -365,29 +391,29 @@ CSH.STRUCT >ENTER 4
jsr CSH.GetCharNB
bcs .99
>LDA.G CSH.hTags
jsr CSH.NewKey
bcs .99
sta (pStack)
jsr CSH.GetNextCharNB
bcs .99
cmp #'{'
bne .99
.1 jsr CSH.GetNextCharNB
bcs .99
cmp #'}'
bne .1
jsr CSH.GetNextCharNB skip }
clc
.99 >LEAVE
rts
rts
*--------------------------------------
* Built in Types
*--------------------------------------
@ -396,25 +422,25 @@ CSH.SIGNED sec
*--------------------------------------
CSH.UNSIGNED clc
php
jsr CSH.CheckSpace
bcs .9
>LDYA L.CSH.STYPES
jsr CSH.LookupID
bcs .9
plp
bcs .8
jmp (J.CSH.UTYPES,x)
.8 jmp (J.CSH.STYPES,x)
.9 plp
lda #CSH.E.SYNTAX
sec
rts
rts
*--------------------------------------
CSH.VOID ldx #CSH.T.VOID
bra CSH.TYPE
@ -436,15 +462,15 @@ CSH.FLOAT ldx #CSH.T.FLOAT
CSH.TYPE stx ZPVarType
jsr CSH.CheckSpace
bcs .9
.11 cmp #'*'
bne .10
lda #CSH.Q.POINTER
tsb ZPVarType
jsr CSH.GetNextCharNB Skip *
bra .11
.10 jsr CSH.IsLetter
bcs .9
@ -465,13 +491,13 @@ CSH.TYPE stx ZPVarType
lda ZPVarType
jsr CSH.ExpEval
bcs .99
.7 jsr CSH.SetVarValueFromStack X= Type, Set value to this var
bcs .99
jsr CSH.GetChar
bcs .9
cmp #';'
bne .9
@ -482,7 +508,7 @@ CSH.TYPE stx ZPVarType
sec
.99 rts
*--------------------------------------
* Input:
* Input:
* ZPFileBufPtr, A = Expected type
* Output:
* CS, A = EC
@ -609,10 +635,9 @@ CSH.fCall ldx ZPPtr1
.99 rts
*--------------------------------------
CSH.fCall.Exec
jmp (J.CSH.EXEC,x)
CSH.fCall.Exec jmp (J.CSH.EXEC,x)
*--------------------------------------
* Input:
* Input:
* ZPFileBufPtr, A = Expected type
* Output:
* CS, A = EC
@ -637,21 +662,21 @@ CSH.ExpEval ldx ZPPtr1
.11 cmp #'('
bne .20
jsr CSH.GetNextCharNB skip (
bcs .19
lda ZPPtr2
jsr CSH.ExpEval
bcs .19
stx ZPPtr2
jsr CSH.GetCharNB
bcs .19
cmp #')'
bne .19
jsr CSH.GetNextCharNB skip )
bcc .31
.19 jmp .90
@ -661,7 +686,7 @@ CSH.ExpEval ldx ZPPtr1
jsr CSH.GetDefine
bcc .10
jsr CSH.GetVar
bcs .21
@ -692,7 +717,7 @@ CSH.ExpEval ldx ZPPtr1
.23 jsr CSH.GetNumOnStack
bcs .29
bra .30
.24 cmp #'"' String literal
bne .90
jsr CSH.AddContCharP
@ -714,28 +739,28 @@ CSH.ExpEval ldx ZPPtr1
>LDYA L.CSH.BOPS we are at V1 op1 V2 op2...
jsr CSH.LookupOP
bcs .90
stx ZPPtr2+1 save OP(n)
.32 pla get OP(n-1)
bmi .33 $ff....
cmp ZPPtr2+1
cmp ZPPtr2+1
bcc .33 OP(n) has precedence, on stack : V1,V2
tax OP(n-1) has precedence...
lda ZPPtr2 Var Type
jsr CSH.BOP.EXEC compute V(n-1) <OP(n-1)> V(n)
bcc .32
bcs .99
.33 pha push back OP(n-1)
lda ZPPtr2+1 get OP(n)
pha push OP(n) on stack
jmp .10 go check for next token
jmp .10 go check for next token
*--------------------------------------
.80 plx any OP on stack ?
bmi .88
@ -743,14 +768,14 @@ CSH.ExpEval ldx ZPPtr1
lda ZPPtr2 Var Type
jsr CSH.BOP.EXEC
bcc .80
bcs .99
.90 lda #CSH.E.SYNTAX
.99 plx
bpl .99
sec
.HS 90 BCC
.88 clc
@ -777,9 +802,9 @@ CSH.AddContCharP
cmp #'"'
beq .2
sta (ZPCSHConst),y
iny
iny
bra .1
.2 lda #0
sta (ZPCSHConst),y
>PUSHW ZPCSHConst Push PTR on stack
@ -854,17 +879,17 @@ CSH.Lookup phy Y = len
jsr CSH.ZPPtr1AddAp1
>LDA.G CSH.LookupOpt
bpl .1
ldy #$0 Start at Y=1 for VOID func()
.6 iny
lda (ZPPtr1),y
bne .6
tya
jsr CSH.ZPPtr1AddAp1
bra .1
.9 pla
sec
rts
@ -872,11 +897,11 @@ CSH.Lookup phy Y = len
CSH.ZPPtr1Next inc ZPPtr1
bne .8
inc ZPPtr1+1
.8 rts
.8 rts
*--------------------------------------
CSH.ZPPtr1AddAp1
sec
adc ZPPtr1
adc ZPPtr1
sta ZPPtr1
bcc .1
inc ZPPtr1+1
@ -946,35 +971,35 @@ CSH.AddVar >LDA.G CSH.hSymbols
ldx ZPVarType
jsr CSH.GetVarSize
sta ZPVarSizeOf
lda ZPCSHData
sta ZPVarDataPtr
clc
adc ZPVarSizeOf
sta ZPCSHData
lda ZPCSHData+1
sta ZPVarDataPtr+1
adc ZPVarSizeOf+1
sta ZPCSHData+1
>LDA.G CSH.DataPtr
clc
adc ZPVarSizeOf
sta (pData),y
bcs .99
>PUSHB.G CSH.hSymbols
>PUSHW ZPVarID
>PUSHWI ZPVarDef
>PUSHWI 6
>SYSCALL SListAddData
* bcs .9
* lda #'*'
* jsr DEBUG.VAR
.9 rts
.99 lda #CSH.E.OOM
@ -994,9 +1019,9 @@ CSH.NewKey >PUSHA
adc ZPFileBufPtr
sta ZPFileBufPtr
bcc .1
inc ZPFileBufPtr+1
.1 clc
pla
.9 rts
@ -1008,19 +1033,19 @@ CSH.SetVarValueFromStack
bne .99
ldy #0
.1 lda (pStack)
sta (ZPVarDataPtr),y
inc pStack
iny
cpy ZPVarSizeOf
bne .1
* lda #'>'
* jsr DEBUG.VAR
clc
rts
.99 lda #CSH.E.TMISMATCH
sec
rts
@ -1029,7 +1054,7 @@ CSH.GetDefine >PUSHB.G CSH.hDefines
jsr CSH.Get
bcs .9
pha
phy
>PUSHB.G CSH.hDefines
@ -1041,23 +1066,23 @@ CSH.GetDefine >PUSHB.G CSH.hDefines
>PUSHWZ len = 0 (string mode)
>PUSHWZ From Start
>SYSCALL SListGetData
bcs .9
bcs .9
stx ZPhMacro
lda ZPFileBufPtr
sta ZPFileBufPtrBak
lda ZPFileBufPtr+1
sta ZPFileBufPtrBak+1
txa
>SYSCALL GetMemPtr
>STYA ZPFileBufPtr
.9 rts
.9 rts
*--------------------------------------
CSH.GetVar >PUSHB.G CSH.hSymbols
CSH.Get >PUSHW ZPFileBufPtr
>SYSCALL SListLookup
bcs .9
@ -1077,7 +1102,7 @@ CSH.Get >PUSHW ZPFileBufPtr
CSH.GetVarDef phy
pha
>PUSHB.G CSH.hSymbols
pla
>PUSHA
pla
@ -1099,7 +1124,7 @@ CSH.GetVarValueOnStack
phy
pha
>PUSHB.G CSH.hSymbols
pla
>PUSHA
pla
@ -1115,17 +1140,17 @@ CSH.GetVarValueOnStack
txa
beq .1 any type
>CMP.G CSH.VarDef Type
beq .2
and #CSH.Q.PPPOINTER
beq .99 not pointer....mismatch
>EOR.G CSH.VarDef
and #CSH.Q.PPPOINTER
bne .99 compare only pointer depth
.1 >LDA.G CSH.VarDef
beq *
@ -1138,9 +1163,9 @@ CSH.GetVarValueOnStack
iny
lda (pData),y
sta ZPPtr3+1
ply
ply
.3 dey
lda (ZPPtr3),y
>PUSHA
@ -1165,10 +1190,10 @@ CSH.IsValue0 cpx #CSH.T.FLOAT
ldy CSH.TYPESIZE,x
lda (ZPVarDataPtr),y
bne .9
.8 clc
rts
.1 jsr CSH.GetVarSize
tax
@ -1178,10 +1203,10 @@ CSH.IsValue0 cpx #CSH.T.FLOAT
inc pStack
dex
bne .2
tax
beq .8
.9 sec
rts
*--------------------------------------
@ -1198,7 +1223,7 @@ CSH.CheckStack tax
clc
rts
.9 lda #CSH.E.SYNTAX
sec
rts
@ -1213,7 +1238,7 @@ CSH.Push pha
sta (ZPCSHStack),y
clc
rts
.9 pla
lda #CSH.E.SOVERFLW
sec
@ -1221,7 +1246,7 @@ CSH.Push pha
*--------------------------------------
CSH.Pop >LDA.G CSH.StackPtr
beq .9
pha
pha
inc
sta (pData),y
ply
@ -1294,7 +1319,7 @@ CSH.SkipBlock ldy #0 not in "", TOTO:skip comments
CSH.GetCharNB jsr CSH.GetChar
bcs CSH.GetNextCharNB.RTS
jsr CSH.CheckCharNB
bcc CSH.GetNextCharNB.RTS
bcc CSH.GetNextCharNB.RTS
*--------------------------------------
CSH.GetNextCharNB
jsr CSH.GetNextChar
@ -1311,7 +1336,7 @@ CSH.CheckSpace jsr CSH.GetChar
jsr CSH.GetNextCharNB
bcc CSH.GetNextCharNB.RTS
.90 lda #CSH.E.SYNTAX
sec
rts
@ -1334,9 +1359,9 @@ CSH.GetChar lda (ZPFileBufPtr)
lda ZPhMacro
beq .9
stz ZPhMacro
phx
phy
>SYSCALL FreeMem
@ -1345,7 +1370,7 @@ CSH.GetChar lda (ZPFileBufPtr)
lda ZPFileBufPtrBak
sta ZPFileBufPtr
lda ZPFileBufPtrBak+1
sta ZPFileBufPtr+1
@ -1402,7 +1427,7 @@ CSH.IsDigit10 cmp #'0'
CSH.GetVarSize txa
and #CSH.Q.PPPOINTER
bne .2
txa
and #$f
phx
@ -1429,6 +1454,6 @@ DEBUG.VAR >SYSCALL PutChar
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CSH.S.CORE
LOAD USR/SRC/BIN/CSH.S
SAVE usr/src/bin/csh.s.core
LOAD usr/src/bin/csh.s
ASM

View File

@ -275,6 +275,6 @@ EXEC.malloc >PULLYA
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CSH.S.EXEC
LOAD USR/SRC/BIN/CSH.S
SAVE usr/src/bin/csh.s.exec
LOAD usr/src/bin/csh.s
ASM

View File

@ -5,12 +5,12 @@ NEW
.OR $2000
.TF bin/csh
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/MLI.I
.INB INC/MLI.E.I
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
.INB inc/mli.e.i
*--------------------------------------
.INB USR/SRC/BIN/CSH.E
.INB usr/src/bin/csh.e
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
@ -21,25 +21,22 @@ ZPFileBuf .BS 2
ZPFileBufPtr .BS 2
ZPFileBufPtrBak .BS 2
ZPCSHConst .BS 2
ZPCSHData .BS 2
ZPCSHStack .BS 2
ZPVarID .BS 2
ZPVarID .BS 2
ZPVarDef .EQ *
ZPVarType .BS 2
ZPVarSizeOf .BS 2
ZPVarDataPtr .BS 2
ZPhMacro .BS 1
ArgIndex .BS 1
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ArgIndex .BS 1
ZPPtr3 .BS 2
ZS.END .ED
@ -70,7 +67,7 @@ L.MSG.ECHOCRLF .DA MSG.ECHOCRLF
L.MSG.DEBUG .DA MSG.DEBUG
L.MSG.ERR .DA MSG.ERR
L.MSG.DBGVAR .DA MSG.DBGVAR
.INB USR/SRC/BIN/CSH.R
.INB usr/src/bin/csh.r
.DA 0
*--------------------------------------
* Called once at process creation
@ -295,8 +292,8 @@ PrintTraceMsg.3 >PUSHBI '>'
rts
*--------------------------------------
.INB USR/SRC/BIN/CSH.S.CORE
.INB USR/SRC/BIN/CSH.S.EXEC
.INB usr/src/bin/csh.s.core
.INB usr/src/bin/csh.s.exec
*--------------------------------------
CS.END
*--------------------------------------
@ -314,16 +311,16 @@ MSG.DBGVAR .AZ "K=%H, T=%H, S=%H, P=%H, V=%L\r\n"
OptionList .AS "DdTt"
OptionVars .DA #bDebug,#bDebug,#bTrace,#bTrace
*--------------------------------------
.INB USR/SRC/BIN/CSH.I
.INB usr/src/bin/csh.i
*--------------------------------------
.DUMMY
.OR 0
DS.START .INB USR/SRC/BIN/CSH.D
DS.START .INB usr/src/bin/csh.d
bDebug .BS 1
bTrace .BS 1
DS.END
.ED
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CSH.S
SAVE usr/src/bin/csh.s
ASM

View File

@ -353,7 +353,7 @@ OPEN.I jsr CLOSE
rts
*--------------------------------------
OPEN.SnY >AR.Sn.SELECT S0.MR
lda #W5100.AR.Sn.MR.IPRAW+W5100.AR.Sn.MR.MF
lda #W5100.AR.Sn.MR.IPRAW
sta W5100.DR,x
>AR.Sn.SELECT S0.PROTO

View File

@ -12,4 +12,4 @@ NEW
short int fopen ( const char *, short int, short int, int );
MAN
SAVE include/A2osX.h
TEXT include/A2osX.h