Kernel 0.94

This commit is contained in:
Rémy GIBERT 2020-02-24 14:33:28 +01:00
parent 13ad12582b
commit d1188bc992
13 changed files with 148 additions and 96 deletions

Binary file not shown.

View File

@ -150,10 +150,13 @@ DIR.DO >LDA.G ASM.DO.StackPtr
inc inc
cmp #DO.MAXDEPTH cmp #DO.MAXDEPTH
bcs .98 bcs .98
jsr SRC.GetNextCharNB jsr SRC.GetNextCharNB
bcs .99 bcs .99
jsr EXP.Eval jsr EXP.Eval
bcs .99 bcs .99
>INC.G ASM.DO.StackPtr >INC.G ASM.DO.StackPtr
* clc ok from bcs .99 * clc ok from bcs .99
adc #ASM.DO.Stack-1 adc #ASM.DO.Stack-1
@ -166,10 +169,12 @@ DIR.DO >LDA.G ASM.DO.StackPtr
lda #$ff lda #$ff
.1 sta (pData),y .1 sta (pData),y
lda #$FF lda #$FF
>STA.G ASM.DO.ON >STA.G ASM.DO.ON
clc clc
rts rts
.98 lda #E.TOO.MANY.DO .98 lda #E.TOO.MANY.DO
sec sec
.99 rts .99 rts
@ -189,8 +194,10 @@ DIR.DU.ERR lda #E.INV.DIR
*--------------------------------------- *---------------------------------------
DIR.ED >LDA.G ASM.DU.ON DIR.ED >LDA.G ASM.DU.ON
bpl DIR.DU.ERR bpl DIR.DU.ERR
lda #0 lda #0
sta (pData),y sta (pData),y
ldy #ASM.PC.DU ldy #ASM.PC.DU
jsr DIR.RestorePC jsr DIR.RestorePC
@ -202,14 +209,17 @@ DIR.ED >LDA.G ASM.DU.ON
*--------------------------------------- *---------------------------------------
DIR.EL >LDA.G ASM.DO.StackPtr DIR.EL >LDA.G ASM.DO.StackPtr
beq .9 beq .9
clc clc
adc #ASM.DO.Stack-1 adc #ASM.DO.Stack-1
tay tay
lda (pData),y lda (pData),y
eor #$ff eor #$ff
sta (pData),y sta (pData),y
clc clc
rts rts
.9 lda #E.ELSE.WITHOUT.DO .9 lda #E.ELSE.WITHOUT.DO
sec sec
rts rts
@ -278,14 +288,17 @@ DIR.EQ clc
DIR.FI ldy #ASM.DO.StackPtr DIR.FI ldy #ASM.DO.StackPtr
lda (pData),y lda (pData),y
beq .99 beq .99
dec dec
sta (pData),y sta (pData),y
bne .1 bne .1
lda #$0 lda #$0
ldy #ASM.DO.ON ldy #ASM.DO.ON
sta (pData),y sta (pData),y
.1 clc .1 clc
rts rts
.99 lda #E.INV.DIR .99 lda #E.INV.DIR
sec sec
rts rts

View File

@ -93,7 +93,7 @@ FIO.OpenFile >STYA ZPPtr1
>PUSHBI 2 >PUSHBI 2
jsr OUT.Print jsr OUT.Print
>LDA.G SRC.COUNT >LDA.G SRC.Depth
cmp #IN.MAXDEPTH cmp #IN.MAXDEPTH
bne .1 bne .1
@ -127,13 +127,13 @@ FIO.OpenFile >STYA ZPPtr1
bcs .99 bcs .99
pha pha
>LDA.G SRC.COUNT >LDA.G SRC.Depth
clc clc
adc #SRC.hFILES adc #SRC.hFILES
tay tay
pla pla
sta (pData),y sta (pData),y
>LDA.G SRC.COUNT >LDA.G SRC.Depth
clc clc
adc #SRC.hFILETYPES adc #SRC.hFILETYPES
tay tay
@ -141,7 +141,7 @@ FIO.OpenFile >STYA ZPPtr1
lda FIO.Stat+S.STAT.P.TYPE lda FIO.Stat+S.STAT.P.TYPE
sta (pData),y sta (pData),y
>INC.G SRC.COUNT >INC.G SRC.Depth
lda #0 lda #0
>STA.G SRC.LINENUM >STA.G SRC.LINENUM
@ -155,7 +155,7 @@ FIO.OpenFile >STYA ZPPtr1
sec sec
.99 rts .99 rts
*--------------------------------------- *---------------------------------------
FIO.ReadLine >LDA.G SRC.COUNT FIO.ReadLine >LDA.G SRC.Depth
clc clc
adc #SRC.hFILETYPES-1 adc #SRC.hFILETYPES-1
tay tay
@ -258,7 +258,7 @@ FIO.ReadLine >LDA.G SRC.COUNT
rts rts
*-------------------------------------- *--------------------------------------
FIO.ReadFromFile FIO.ReadFromFile
>LDA.G SRC.COUNT >LDA.G SRC.Depth
clc clc
adc #SRC.hFILES-1 adc #SRC.hFILES-1
tay tay
@ -272,7 +272,7 @@ FIO.ReadFromFile
sec sec
.9 rts .9 rts
*--------------------------------------- *---------------------------------------
FIO.FileClose >LDA.G SRC.COUNT FIO.FileClose >LDA.G SRC.Depth
beq .8 beq .8
dec dec

View File

@ -265,21 +265,20 @@ MAC.ReadLine >LDA.G MAC.hBuf
lda (ZPMacroBuf) lda (ZPMacroBuf)
beq .9 beq .9
inc ZPMacroBuf inc ZPMacroBuf
bne .21 bne .21
inc ZPMacroBuf+1 inc ZPMacroBuf+1
.21 cmp #'#' .21 cmp #'#'
bne .20 bne .20
>LDYA ZPMacroBuf
>SYSCALL puts
>DEBUG
jsr MAC.GetArgCnt jsr MAC.GetArgCnt
ora #$30 ora #$30
bra .7 sta (ZPLineBuf),y
iny
bra .1
.20 cmp #'1' .20 cmp #'1'
bcc .9 bcc .9
@ -430,7 +429,7 @@ MAC.GetArgCnt phy
.1 iny .1 iny
lda (ZPMacroArgBuf),y lda (ZPMacroArgBuf),y
beq .8 beq .7
cmp #',' cmp #','
bne .1 bne .1

View File

@ -61,27 +61,39 @@ OUT.PrintLineErr
>PUSHBI 1 >PUSHBI 1
>SYSCALL printf >SYSCALL printf
ldx ZPLinePtr lda ZPLinePtr
cpx ZPLineBuf sec
beq .4 sbc ZPLineBuf
jsr OUT.PrintLineErrDashA
.3 phx >LDA.G SRC.Depth
jsr OUT.PrintLineErrDashA
>LDA.G MAC.Depth
jsr OUT.PrintLineErrDashA
lda #'^'
>SYSCALL PutChar
bcs .9
jmp OUT.PrintCR
.9 rts
*---------------------------------------
OUT.PrintLineErrDashA
tax
beq .8
.1 phx
lda #'-' lda #'-'
>SYSCALL PutChar >SYSCALL PutChar
plx plx
bcs .9 bcs .9
dex dex
cpx ZPLineBuf bne .1
bne .3
.4 lda #'^' .8 clc
phy
>SYSCALL PutChar
ply
bcs .9
jmp OUT.PrintCR
.9 rts .9 rts
*--------------------------------------- *---------------------------------------
OUT.PrintLine jsr OUT.PrintLineOn OUT.PrintLine jsr OUT.PrintLineOn
@ -90,7 +102,7 @@ OUT.PrintLine jsr OUT.PrintLineOn
OUT.PrintLine.1 jsr OUT.PrintLineOutBuf OUT.PrintLine.1 jsr OUT.PrintLineOutBuf
bcs OUT.Print.RTS bcs OUT.Print.RTS
>LDA.G SRC.COUNT >LDA.G SRC.Depth
.1 dec .1 dec
beq .2 beq .2

View File

@ -4,20 +4,19 @@ NEW
SRC.ParseLine jsr OUT.Reset SRC.ParseLine jsr OUT.Reset
jsr SRC.GetChar jsr SRC.GetChar
bcs .8 bcs .8
cmp #'*' Comment? cmp #'*' Comment?
beq .8 beq .8
cmp #';' Comment? cmp #';' Comment?
beq .8 beq .8
>LDA.G ASM.DO.StackPtr
beq .1 pha
jsr SRC.DoCheck
pla
bcc SRC.ParseLine.DirOp false....skip label processing
clc >LDA.G ASM.MA.ON
adc #ASM.DO.Stack-1
tay
lda (pData),y
beq .8
.1 >LDA.G ASM.MA.ON
bpl SRC.ParseLine.LABEL bpl SRC.ParseLine.LABEL
jmp MAC.Learn jmp MAC.Learn
@ -78,16 +77,29 @@ SRC.ParseLine.DirOp
jsr SRC.GetNextChar jsr SRC.GetNextChar
bcs SRC.ParseLine.InvDir bcs SRC.ParseLine.InvDir
jsr SRC.ParseLine.Dir >LDYA L.T.DIRECTIVES
bcs SRC.ParseLine.Err jsr SRC.GetKeyword
bra SRC.ParseLine.Ok bcs SRC.ParseLine.InvDir
jsr SRC.DoCheck
bcs .1 TRUE, always execute
.5 cmp #'>' cpx #20 .ELSE?
beq .1
cpx #20 .FIN?
bne SRC.ParseLine.Ok
.1 jmp (J.DIRECTIVES,x)
.5 pha
jsr SRC.DoCheck
pla
bcc SRC.ParseLine.Err FALSE, skip all
cmp #'>'
bne SRC.ParseLine.OpCode bne SRC.ParseLine.OpCode
jsr MAC.Exec jmp MAC.Exec
bcs SRC.ParseLine.Err
bra SRC.ParseLine.Ok
SRC.ParseLine.Ok SRC.ParseLine.Ok
clc clc
SRC.ParseLine.Err SRC.ParseLine.Err
@ -102,11 +114,7 @@ SRC.ParseLine.InvDir
sec sec
rts rts
*--------------------------------------- *---------------------------------------
SRC.ParseLine.Dir SRC.ParseLine.DirJmp
>LDYA L.T.DIRECTIVES
jsr SRC.GetKeyword
bcs SRC.ParseLine.InvDir
jmp (J.DIRECTIVES,x) jmp (J.DIRECTIVES,x)
*--------------------------------------- *---------------------------------------
SRC.ParseLine.OpCode SRC.ParseLine.OpCode
@ -894,6 +902,18 @@ SRC.ACC10 lda SRC.ACC ACC*2-> ACC & ACCTMP
sta SRC.ACC+3 CS if overflow sta SRC.ACC+3 CS if overflow
.9 rts .9 rts
*--------------------------------------- *---------------------------------------
SRC.DoCheck sec
>LDA.G ASM.DO.StackPtr
beq .8
clc
adc #ASM.DO.Stack-1
tay
lda (pData),y
asl
.8 rts CS if TRUE
*---------------------------------------
DEBUG.PSTR pha DEBUG.PSTR pha
>PUSHW L.MSG.PSTR >PUSHW L.MSG.PSTR
pla pla

View File

@ -79,20 +79,24 @@ SYM.Dump >LDA.G ASM.LI.ON
ldy #SYMG.SIZE Get Symbol Size ldy #SYMG.SIZE Get Symbol Size
lda (ZPSymbolBuf),y lda (ZPSymbolBuf),y
tax
beq .3
phx
pha
asl asl
tax tax
>PUSHB L.MSG.EQU0+1,x >PUSHB L.MSG.EQU0+1,x
>PUSHB L.MSG.EQU0,x >PUSHB L.MSG.EQU0,x
plx pla
phx pha
tax byte count
.2 iny clc
adc #SYMG.V
tay
.2 dey
lda (ZPSymbolBuf),y lda (ZPSymbolBuf),y
>PUSHA >PUSHA
dex dex
@ -129,34 +133,26 @@ SYM.Dump.LP ldy #SYMG
iny iny
lda (ZPSymbolBuf),y MacID lda (ZPSymbolBuf),y MacID
beq .2 bne .3
>PUSHW L.MSG.LSYMBOL >PUSHW L.MSG.LSYMBOL
txa txa
>PUSHA >PUSHA
>PUSHB (ZPSymbolBuf),y jsr SYM.Dump.PushValueY
bra .3
.2 >PUSHW L.MSG.LSYMBOL lda #5
bra .5
.3 >PUSHW L.MSG.PSYMBOL
txa txa
>PUSHA >PUSHA
phx >PUSHB (ZPSymbolBuf),y
jsr SYM.Dump.PushValueY
.3 ldx #4 lda #6
.4 iny
lda (ZPSymbolBuf),y
>PUSHA
dex
bne .4
lda #5
plx
beq .5
inc
.5 >PUSHA .5 >PUSHA
@ -171,6 +167,22 @@ SYM.Dump.LP ldy #SYMG
.8 rts .8 rts
*--------------------------------------- *---------------------------------------
SYM.Dump.PushValueY
ldx #4
iny
iny
iny
iny
.1 lda (ZPSymbolBuf),y
>PUSHA
dey
dex
bne .1
rts
*---------------------------------------
SYM.NewOrGetGlobal SYM.NewOrGetGlobal
>LDA.G ASM.PASS >LDA.G ASM.PASS
bne SYM.GetGlobal bne SYM.GetGlobal

View File

@ -287,7 +287,7 @@ CS.RUN ldy #S.PS.hStdIn
.11 >STZ.G bPause .11 >STZ.G bPause
.12 >LDA.G SRC.COUNT root file is already opened? .12 >LDA.G SRC.Depth root file is already opened?
bne .10 bne .10
>PUSHW L.MSG.PASS >PUSHW L.MSG.PASS
@ -328,7 +328,7 @@ CS.RUN ldy #S.PS.hStdIn
bne .9 bne .9
jsr FIO.FileClose jsr FIO.FileClose
>LDA.G SRC.COUNT end of root file ? >LDA.G SRC.Depth end of root file ?
bne .8 no continue back to previous file bne .8 no continue back to previous file
jsr SYM.StoreGlobal Make sure last Global flushed jsr SYM.StoreGlobal Make sure last Global flushed
@ -352,14 +352,15 @@ CS.RUN ldy #S.PS.hStdIn
bcs .9 bcs .9
jsr OUT.PrintLine jsr OUT.PrintLine
.8 clc .8 clc
rts rts
.9 pha .9 pha
jsr OUT.PrintLineErr jsr OUT.PrintLineErr
jsr SYM.StoreGlobal Make sure last Global flushed * jsr SYM.StoreGlobal Make sure last Global flushed
jsr SYM.Dump * jsr SYM.Dump
pla pla
sec sec
rts rts
@ -481,7 +482,7 @@ MSG.SYMBOLS .AZ "Symbol Table:"
MSG.LSYMBOL .AZ " .%d=%h%h%h%h" MSG.LSYMBOL .AZ " .%d=%h%h%h%h"
MSG.PSYMBOL .AZ " :%d(%d)=%h%h%h%h" MSG.PSYMBOL .AZ " :%d(%d)=%h%h%h%h"
MSG.SUMMARY .AZ "\r\nSymbol Table Size : %5D Bytes.\r\n" MSG.SUMMARY .AZ "\r\nSymbol Table Size : %5D Bytes.\r\n"
MSG.END .AZ "End Of Assembly." MSG.END .AZ "**** End Of Assembly."
MSG.PSTR .AS "{%S}" MSG.PSTR .AS "{%S}"
MSG.CRLF .AZ "\r\n" MSG.CRLF .AZ "\r\n"
MSG.WORD .AZ ">$%H" MSG.WORD .AZ ">$%H"
@ -510,7 +511,7 @@ SRC.hFILENAME .BS 1
SRC.hLineBuf .BS 1 SRC.hLineBuf .BS 1
SRC.hTmpBuf .BS 1 SRC.hTmpBuf .BS 1
SRC.COUNT .BS 1 SRC.Depth .BS 1
SRC.hFILES .BS IN.MAXDEPTH SRC.hFILES .BS IN.MAXDEPTH
SRC.hFILETYPES .BS IN.MAXDEPTH SRC.hFILETYPES .BS IN.MAXDEPTH

View File

@ -757,7 +757,7 @@ CMD.CASE jsr CORE.StkGetCtx Get context in CORE.TestResult
cmp #C.CASE cmp #C.CASE
bne .9 bne .9
txa previous case was true ? txa previous case was true ?
bpl .10 bpl .10
jsr EXP.GET skip expression jsr EXP.GET skip expression
bcs .9 bcs .9
rts keep existing context rts keep existing context
@ -845,7 +845,7 @@ CMD.FOR jsr CORE.StkGetCtx
cmp #'(' cmp #'('
beq CMD.FOR.FILE beq CMD.FOR.FILE
cmp #'`' cmp #'`'
beq CMD.FOR.EXEC beq CMD.FOR.EXEC
*-------------------------------------- *--------------------------------------
CMD.FOR.LIST >LDYA ZPArgVBufPtr CMD.FOR.LIST >LDYA ZPArgVBufPtr
>SYSCALL strdup >SYSCALL strdup

View File

@ -3,7 +3,7 @@ NEW
.LIST OFF .LIST OFF
.OP 65C02 .OP 65C02
.OR $2000 .OR $2000
.TF BIN/TERM .TF bin/term
*-------------------------------------- *--------------------------------------
.INB INC/MACROS.I .INB INC/MACROS.I
.INB INC/A2OSX.I .INB INC/A2OSX.I
@ -17,7 +17,6 @@ BUFSIZE .EQ 256
.DUMMY .DUMMY
.OR ZPBIN .OR ZPBIN
ZS.START ZS.START
ZPDevName .BS 2
ZPBufPtr .BS 2 ZPBufPtr .BS 2
ZPBufLen .BS 2 ZPBufLen .BS 2
hBuf .BS 1 hBuf .BS 1
@ -54,12 +53,11 @@ CS.INIT clc
CS.RUN lda #1 CS.RUN lda #1
>SYSCALL ArgV >SYSCALL ArgV
bcs .9 bcs .9
>STYA ZPDevName
>PUSHWZ auxtype >PUSHYA
>PUSHBI 0 type >PUSHBI O.RDWR
>PUSHBI O.RDWR >PUSHBI O.RDWR
>LDYA ZPDevName >PUSHBI 0 type
>PUSHWZ auxtype
>SYSCALL fopen >SYSCALL fopen
bcs .99 bcs .99

View File

@ -199,6 +199,7 @@ CS.RUN ldy #S.PS.hStdIn
ldy #hSrcFullPath ldy #hSrcFullPath
jsr CS.RUN.GetPathY jsr CS.RUN.GetPathY
>PUSHYA
>SYSCALL remove >SYSCALL remove
bcs .22 bcs .22
jsr CS.RUN.CheckErr Success!!! jsr CS.RUN.CheckErr Success!!!

View File

@ -41,7 +41,7 @@ K.SListSetData >PULLW ZPSListDataLen
* ## ASM * ## ASM
* `>PUSHB hSList` * `>PUSHB hSList`
* `>PUSHW KeyID` * `>PUSHW KeyID`
* `>PUSHW DataPtr` * `>PUSHW KeyPtr`
* `>SYSCALL SListGetByID` * `>SYSCALL SListGetByID`
* ## RETURN VALUE * ## RETURN VALUE
* Y,A = Next KeyID * Y,A = Next KeyID

View File

@ -208,9 +208,7 @@ SLISTX.SListGetByID
jsr SLIST.GetNextByte jsr SLIST.GetNextByte
ply ply
sta CLRWRITEAUX jsr SHARED.FORPNT.PutNext
sta (TXTPTR),y
sta SETWRITEAUX
iny iny
dex dex
@ -218,9 +216,7 @@ SLISTX.SListGetByID
txa lda #0 txa lda #0
sta CLRWRITEAUX jsr SHARED.FORPNT.PutNext
sta (TXTPTR),y
sta SETWRITEAUX
jsr SLIST.SkipData jsr SLIST.SkipData
>LDYA SLIST.KeyID >LDYA SLIST.KeyID