Kernel 0.9.1 : ASM rewrite....Symbols DB

This commit is contained in:
Rémy GIBERT 2018-01-24 16:24:06 +00:00
parent f2cbecc25f
commit cc36ac74e5
8 changed files with 145 additions and 93 deletions

Binary file not shown.

Binary file not shown.

View File

@ -176,14 +176,17 @@ DIR.EP ldy #ASM.PH.ON
sec sec
rts rts
*--------------------------------------- *---------------------------------------
DIR.EQ jsr SRC.GetNextCharNB DIR.EQ >LDA.G SYM.bGlobal
beq .99
jsr SRC.GetNextCharNB
bcs .99 bcs .99
jsr EXP.Eval jsr EXP.Eval
bcs .9 bcs .9
* jsr SYM.UpdateGlobal jsr SYM.UpdateGlobalAcc
* bcs .9 bcs .9
clc clc
rts rts

View File

@ -72,6 +72,7 @@ EXP.Eval.Next1 cmp #'.' Local Label?
.2 cmp #'%' binary? .2 cmp #'%' binary?
bne .3 bne .3
jsr SRC.GetBinary jsr SRC.GetBinary
bcs EXP.EvalExitSYN bcs EXP.EvalExitSYN
@ -125,8 +126,7 @@ EXP.EvalExitSYN lda #ERR.SYNTAX.ERROR
EXP.EvalExitUND lda #ERR.UNDEF.SYMBOL EXP.EvalExitUND lda #ERR.UNDEF.SYMBOL
sec sec
rts rts
EXP.EvalOperator lda EXP.Operator EXP.EvalOperator lda EXP.Operator
beq .7 beq .7
@ -148,6 +148,7 @@ EXP.EvalOperator lda EXP.Operator
stx EXP.Operator stx EXP.Operator
ldx #3 ldx #3
.8 lda SRC.ACC,x .8 lda SRC.ACC,x
sta SRC.ARG,x sta SRC.ARG,x
dex dex

View File

@ -2,7 +2,9 @@ NEW
PREFIX /A2OSX.BUILD PREFIX /A2OSX.BUILD
AUTO 4,1 AUTO 4,1
*--------------------------------------- *---------------------------------------
SRC.PrintLine >LDA.G ASM.MACRO.ON SRC.PrintLine bra .8
>LDA.G ASM.MACRO.ON
bpl .1 bpl .1
>LDA.G ASM.LI.CON >LDA.G ASM.LI.CON
@ -54,7 +56,7 @@ SRC.PrintLineErr >PUSHW ZPLineBuf
.9 rts .9 rts
*--------------------------------------- *---------------------------------------
SRC.ParseLine lda #0 SRC.ParseLine lda #0
>STA.G SYM.bGlobalUpdate >STA.G SYM.bGlobal
jsr SRC.GetChar jsr SRC.GetChar
bcs .8 bcs .8
@ -84,14 +86,25 @@ SRC.ParseLine lda #0
jsr SYM.AddLocal jsr SYM.AddLocal
bra .3 bra .7
.8 clc .8 clc
rts rts
.2 jsr SYM.AddGlobalPC .2 lda #$ff
>STA.G SYM.bGlobal
.3 bcs SRC.ParseLine.Err >LDA.G ASM.PASS
beq .6
jsr SYM.LookupGlobal
bcs SRC.ParseLine.Undef
jsr SYM.UpdateGlobal
bra SRC.ParseLine.DirOp
.6 jsr SYM.AddGlobalPC
.7 bcs SRC.ParseLine.Redef
SRC.ParseLine.DirOp jsr SRC.GetNextCharNB Scan for an Opcode... SRC.ParseLine.DirOp jsr SRC.GetNextCharNB Scan for an Opcode...
bcs SRC.ParseLine.Ok bcs SRC.ParseLine.Ok
@ -116,29 +129,7 @@ SRC.ParseLine.DirOp jsr SRC.GetNextCharNB Scan for an Opcode...
.6 jsr SRC.ParseLine.OpCode .6 jsr SRC.ParseLine.OpCode
bcs SRC.ParseLine.Err bcs SRC.ParseLine.Err
SRC.ParseLine.Ok >LDA.G SYM.bGlobalUpdate SRC.ParseLine.Ok clc
bpl .8
bra .8
ldy #ASM.PASS
lda (pData),y pass#2?
bne .8 yes, nothing to do
* --- Pass #1
>LDA.G SYM.Global+SYM.F
bit #SYM.F.RESOLVED found symbol pending ?
bne .2 yes, update
bit #SYM.F.RW found is .SE ?
beq SRC.ParseLine.Redef no, redefine error
.2 jsr SYM.UpdateGlobal
bra .8
.8 clc
rts rts
SRC.ParseLine.InvLbl SRC.ParseLine.InvLbl
@ -146,10 +137,13 @@ SRC.ParseLine.InvLbl
SRC.ParseLine.Err sec SRC.ParseLine.Err sec
rts rts
SRC.ParseLine.Redef lda #ERR.SYMBOL.REDEFINE SRC.ParseLine.Redef lda #ERR.SYMBOL.REDEF
sec sec
rts rts
SRC.ParseLine.Undef lda #ERR.UNDEF.SYMBOL
sec
rts
SRC.ParseLine.InvDir SRC.ParseLine.InvDir
lda #ERR.INV.DIR lda #ERR.INV.DIR
sec sec

View File

@ -70,6 +70,7 @@ SYM.Dump >LDYA L.MSG.SYMBOLS
>LDYA L.MSG.GSYMBOL >LDYA L.MSG.GSYMBOL
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
>DEBUG
bcc .1 bcc .1
rts rts
@ -99,7 +100,7 @@ SYM.AddGlobalPC ldx #4
SYM.AddGlobal lda #SYM.F.RESOLVED SYM.AddGlobal lda #SYM.F.RESOLVED
>STA.G SYM.Global+SYM.F >STA.G SYM.Global+SYM.F
lda #6 LEN+F+DWORD lda #5 F+DWORD
>STA.G SYM.Global+SYM.LEN >STA.G SYM.Global+SYM.LEN
>PUSHB.G SYM.hGlobals >PUSHB.G SYM.hGlobals
@ -118,14 +119,53 @@ SYM.AddGlobal lda #SYM.F.RESOLVED
clc clc
.1 tya .1 tya
>STA.G ASM.SYM.ID+1 >STA.G SYM.ID+1
dey dey
txa txa
sta (pData),y sta (pData),y
.9 rts .9 rts
*--------------------------------------- *---------------------------------------
SYM.UpdateGlobal >PUSHB.G SYM.hGlobals SYM.LookupGlobal >PUSHB.G SYM.hGlobals
>PUSHW.G ASM.SYM.ID >PUSHW ZPLinePtr
>PUSHEA.G SYM.Lookup
>SYSCALL SListLookup
bcs .9
adc ZPLinePtr
sta ZPLinePtr
bcc .1
inc ZPLinePtr+1
clc
.1 tya
>STA.G SYM.ID+1
txa
>STA.G SYM.ID
.9 rts
*---------------------------------------
SYM.UpdateGlobalAcc ldx #3
ldy #SYM.Global+SYM.V+3
.1 lda SRC.ACC,x
sta (pData),y
dey
dex
bpl .1
*---------------------------------------
SYM.UpdateGlobal lda #SYM.F.RESOLVED
>STA.G SYM.Global+SYM.F
lda #5 F+DWORD
>STA.G SYM.Global+SYM.LEN
>PUSHB.G SYM.hGlobals
>PUSHW.G SYM.ID
>PUSHEA.G SYM.Global >PUSHEA.G SYM.Global
>SYSCALL SListUpdateByID >SYSCALL SListUpdateByID

View File

@ -49,7 +49,7 @@ ERR.INV.AM.SYN .EQ $A7
ERR.INV.AM.4.OC .EQ $A8 ERR.INV.AM.4.OC .EQ $A8
ERR.RANGE .EQ $A9 ERR.RANGE .EQ $A9
ERR.UNDEF.SYMBOL .EQ $AA ERR.UNDEF.SYMBOL .EQ $AA
ERR.SYMBOL.REDEFINE .EQ $AB ERR.SYMBOL.REDEF .EQ $AB
ERR.TOO.MANY.DO .EQ $AC ERR.TOO.MANY.DO .EQ $AC
ERR.MISSING.EXP .EQ $B0 ERR.MISSING.EXP .EQ $B0
ERR.EXP.SYN.ERROR .EQ $B1 ERR.EXP.SYN.ERROR .EQ $B1
@ -215,8 +215,7 @@ CS.RUN >SYSCALL GetChar
lda (pData),y lda (pData),y
bne .10 bne .10
ldy #ASM.PASS >LDA.G ASM.PASS
lda (pData),y
inc inc
>PUSHA >PUSHA
>LDYA L.MSG.PASS >LDYA L.MSG.PASS
@ -241,8 +240,7 @@ CS.RUN >SYSCALL GetChar
lda (pData),y lda (pData),y
bne .8 no continue back to previous file bne .8 no continue back to previous file
ldy #ASM.PASS >LDA.G ASM.PASS End of pass #2 ??
lda (pData),y End of pass #2 ??
bne .1 bne .1
inc inc
sta (pData),y sta (pData),y
@ -270,15 +268,14 @@ CS.RUN >SYSCALL GetChar
.9 pha .9 pha
jsr SRC.PrintLineErr jsr SRC.PrintLineErr
>DEBUG
jsr SYM.Dump
pla pla
pha pha
>PUSHA >PUSHA
>PUSHW SRC.LINENUM >PUSHW SRC.LINENUM
>LDYA L.MSG.ERROR >LDYA L.MSG.ERROR
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
jsr SYM.Dump
pla pla
sec sec
rts rts
@ -380,7 +377,7 @@ MSG.SRCLINE >CSTR "%H- %05D %s\r\n"
MSG.LINECR >CSTR "%s\r\n" MSG.LINECR >CSTR "%s\r\n"
MSG.ERROR >CSTR "%05D-Error:$%h\r\n" MSG.ERROR >CSTR "%05D-Error:$%h\r\n"
MSG.SYMBOLS >CSTR "Symbol Table:\r\n" MSG.SYMBOLS >CSTR "Symbol Table:\r\n"
MSG.GSYMBOL >CSTR "$%H%H:%S\r\n" MSG.GSYMBOL >CSTR "$%h%h%h%h:%S\r\n"
MSG.SUMMARY >CSTR "\r\nEnd Of Assembly.\r\n" MSG.SUMMARY >CSTR "\r\nEnd Of Assembly.\r\n"
SRC.AM.RESERVED >PSTR "[]()," SRC.AM.RESERVED >PSTR "[](),"
SRC.MOD.RESERVED >PSTR "#/<>" SRC.MOD.RESERVED >PSTR "#/<>"
@ -441,12 +438,12 @@ ASM.PC.PH .BS 4
ASM.PC.GLABEL .BS 4 ASM.PC.GLABEL .BS 4
ASM.LOCAL.OFFSET .BS 1 ASM.LOCAL.OFFSET .BS 1
ASM.LOCAL.INVALID .BS 1 ASM.LOCAL.INVALID .BS 1
ASM.SYM.ID .BS 2
SYM.hGlobals .BS 1 SYM.hGlobals .BS 1
SYM.bGlobalUpdate .BS 1 SYM.bGlobal .BS 1
SYM.Global .BS 6 SYM.Global .BS 6
SYM.ID .BS 1 SYM.Lookup .BS 6
SYM.ID .BS 2
DS.END .ED DS.END .ED
*--------------------------------------- *---------------------------------------
.DO DS.END-DS.START>$FF .DO DS.END-DS.START>$FF

View File

@ -11,7 +11,7 @@ X.SLIST jmp (.1-SYS.SListAdd,x)
.DA SLIST.Free.A .DA SLIST.Free.A
*-------------------------------------- *--------------------------------------
SLIST.Add jsr SLIST.Search SLIST.Add jsr SLIST.Search
bcc .9 Lookup succeeded...DUP bcc .99 Lookup succeeded...DUP
ldy #$ff ldy #$ff
@ -40,7 +40,7 @@ SLIST.Add jsr SLIST.Search
jsr MEM.GetDataByteY jsr MEM.GetDataByteY
tax tax
>DEBUG
jsr SLIST.AddBlockByte jsr SLIST.AddBlockByte
bcs .9 bcs .9
@ -58,8 +58,12 @@ SLIST.Add jsr SLIST.Search
ldy SLIST.ID+1 ldy SLIST.ID+1
clc clc
.9 rts .9 rts
.99 sec
rts
*-------------------------------------- *--------------------------------------
SLIST.Lookup jsr SLIST.Search SLIST.Lookup jsr SLIST.Search
bcs .9 bcs .9
sty .8+1 sty .8+1
@ -70,7 +74,7 @@ SLIST.Lookup jsr SLIST.Search
tax tax
jsr MEM.SetDataByteY jsr MEM.SetDataByteY
.1 jsr SLIST.GetBlockByte .1 jsr SLIST.NextBlockByte
iny iny
jsr MEM.SetDataByteY jsr MEM.SetDataByteY
dex dex
@ -83,33 +87,36 @@ SLIST.Lookup jsr SLIST.Search
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
SLIST.GetByID jsr SLIST.Select SLIST.GetByID jsr SLIST.Select
jsr SLIST.GetBlockByte jsr SLIST.GetBlockByte
bcs .9
tax tax
beq .9
ldy #0 ldy #0
jsr MEM.SetDataByteY jsr MEM.SetDataByteY
.1 jsr SLIST.GetBlockByte .1 jsr SLIST.NextBlockByte
iny iny
jsr MEM.SetDataByteY jsr MEM.SetDataByteY
dex dex
bne .1 bne .1
jsr SLIST.GetBlockByte jsr SLIST.NextBlockByte
tax tax
iny iny
jsr MEM.SetDataByteY jsr MEM.SetDataByteY
.2 jsr SLIST.GetBlockByte .2 jsr SLIST.NextBlockByte
iny iny
jsr MEM.SetDataByteY jsr MEM.SetDataByteY
dex dex
bne .2 bne .2
jsr SLIST.NextBlockByte
lda SLIST.IndexOfs lda SLIST.IndexOfs
ldy SLIST.BlockOfs ldy SLIST.BlockOfs
@ -123,27 +130,32 @@ SLIST.GetByID jsr SLIST.Select
SLIST.UpdateByID SLIST.UpdateByID
jsr SLIST.Select jsr SLIST.Select
jsr SLIST.GetBlockByte
tax
.1 jsr SLIST.NextBlockByte
dex
bne .1
jsr SLIST.NextBlockByte set pos at DATALEN
ldy #0 ldy #0
jsr MEM.GetDataByteY jsr MEM.GetDataByteY
tax tax
jsr SLIST.SetBlockByte jsr SLIST.SetBlockByte
bcs .9
.4 iny .4 iny
jsr MEM.GetDataByteY jsr MEM.GetDataByteY
jsr SLIST.SetBlockByte jsr SLIST.SetBlockByte
bcs .9
dex dex
bne .4 bne .4
.8 lda #$ff SELF MODIFIED
clc clc
.9 rts rts
*-------------------------------------- *--------------------------------------
SLIST.New >LDYAI 160 40k Max before out of memory!!! SLIST.New >LDYAI 160 40k Max before out of memory!!!
jsr K.GetMem0.YA jsr K.GetMem0.YA
@ -196,67 +208,74 @@ SLIST.Search jsr K.GetMemPtr.A
>STYA ZPSListIndex >STYA ZPSListIndex
stz SLIST.IndexOfs stz SLIST.IndexOfs
stz SLIST.ID+1
lda (ZPSListIndex) lda (ZPSListIndex)
jsr K.GetMemPtr.A jsr K.GetMemPtr.A
>STYA ZPSListBlock >STYA ZPSListBlock
stz SLIST.BlockOfs stz SLIST.BlockOfs
stz SLIST.ID
.1 lda SLIST.IndexOfs
sta SLIST.ID
lda SLIST.BlockOfs
sta SLIST.ID+1
jsr SLIST.GetBlockByte jsr SLIST.GetBlockByte
tax tax
beq .9 beq .9
ldy #0 .1 ldy #0
.2 jsr MEM.GetKeyCharY .2 jsr MEM.GetKeyCharY
bcs .4 bcs .4
iny iny
sta .3+1 sta .3+1
jsr SLIST.GetBlockByte jsr SLIST.NextBlockByte
.3 cmp #$ff SELF MODIFIED .3 cmp #$ff SELF MODIFIED
bne .4 bne .4
dex dex
bne .2 bne .2
jsr MEM.GetKeyCharY
bcs .8 End of Key....match!!!!
jsr SLIST.NextBlockByte
bra .41
.8 jsr SLIST.NextBlockByte Advance to DATA LEN
clc Y = Key Length clc Y = Key Length
rts rts
.4 jsr SLIST.GetBlockByte skip remaining key chars .4 jsr SLIST.NextBlockByte skip remaining key chars
dex dex
bne .4 bne .4
jsr SLIST.GetBlockByte get Data Len .41 tax A=get Data Len
tax
.5 jsr SLIST.GetBlockByte skip data bytes .5 jsr SLIST.NextBlockByte skip data bytes
dex dex
bne .5 bne .5
bra .1 jsr SLIST.NextBlockByte
ldx SLIST.IndexOfs
stx SLIST.ID+1
ldx SLIST.BlockOfs
stx SLIST.ID
tax
bne .1
.9 sec .9 sec
rts rts
*-------------------------------------- *--------------------------------------
SLIST.GetBlockByte SLIST.NextBlockByte
phy
ldy SLIST.BlockOfs
lda (ZPSListBlock),y
beq .99
inc SLIST.BlockOfs inc SLIST.BlockOfs
bne .8 bne SLIST.GetBlockByte
pha phy
inc SLIST.IndexOfs inc SLIST.IndexOfs
ldy SLIST.IndexOfs ldy SLIST.IndexOfs
lda (ZPSListIndex),y lda (ZPSListIndex),y
@ -264,17 +283,15 @@ SLIST.GetBlockByte
jsr K.GetMemPtr.A jsr K.GetMemPtr.A
>STYA ZPSListBlock >STYA ZPSListBlock
* stz SLIST.BlockOfs * stz SLIST.BlockOfs
.HS A9 lda imm
pla SLIST.GetBlockByte
phy
ldy SLIST.BlockOfs
lda (ZPSListBlock),y
.8 ply ply
clc clc
rts rts
.9 pla
.99 ply
sec
rts
*-------------------------------------- *--------------------------------------
SLIST.AddBlockByte SLIST.AddBlockByte
phy phy