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
rts
*---------------------------------------
DIR.EQ jsr SRC.GetNextCharNB
DIR.EQ >LDA.G SYM.bGlobal
beq .99
jsr SRC.GetNextCharNB
bcs .99
jsr EXP.Eval
bcs .9
* jsr SYM.UpdateGlobal
* bcs .9
jsr SYM.UpdateGlobalAcc
bcs .9
clc
rts

View File

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

View File

@ -2,7 +2,9 @@ NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
*---------------------------------------
SRC.PrintLine >LDA.G ASM.MACRO.ON
SRC.PrintLine bra .8
>LDA.G ASM.MACRO.ON
bpl .1
>LDA.G ASM.LI.CON
@ -54,7 +56,7 @@ SRC.PrintLineErr >PUSHW ZPLineBuf
.9 rts
*---------------------------------------
SRC.ParseLine lda #0
>STA.G SYM.bGlobalUpdate
>STA.G SYM.bGlobal
jsr SRC.GetChar
bcs .8
@ -84,14 +86,25 @@ SRC.ParseLine lda #0
jsr SYM.AddLocal
bra .3
bra .7
.8 clc
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...
bcs SRC.ParseLine.Ok
@ -116,29 +129,7 @@ SRC.ParseLine.DirOp jsr SRC.GetNextCharNB Scan for an Opcode...
.6 jsr SRC.ParseLine.OpCode
bcs SRC.ParseLine.Err
SRC.ParseLine.Ok >LDA.G SYM.bGlobalUpdate
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
SRC.ParseLine.Ok clc
rts
SRC.ParseLine.InvLbl
@ -146,10 +137,13 @@ SRC.ParseLine.InvLbl
SRC.ParseLine.Err sec
rts
SRC.ParseLine.Redef lda #ERR.SYMBOL.REDEFINE
SRC.ParseLine.Redef lda #ERR.SYMBOL.REDEF
sec
rts
SRC.ParseLine.Undef lda #ERR.UNDEF.SYMBOL
sec
rts
SRC.ParseLine.InvDir
lda #ERR.INV.DIR
sec

View File

@ -70,6 +70,7 @@ SYM.Dump >LDYA L.MSG.SYMBOLS
>LDYA L.MSG.GSYMBOL
>SYSCALL PrintF.YA
>DEBUG
bcc .1
rts
@ -99,7 +100,7 @@ SYM.AddGlobalPC ldx #4
SYM.AddGlobal lda #SYM.F.RESOLVED
>STA.G SYM.Global+SYM.F
lda #6 LEN+F+DWORD
lda #5 F+DWORD
>STA.G SYM.Global+SYM.LEN
>PUSHB.G SYM.hGlobals
@ -118,14 +119,53 @@ SYM.AddGlobal lda #SYM.F.RESOLVED
clc
.1 tya
>STA.G ASM.SYM.ID+1
>STA.G SYM.ID+1
dey
txa
sta (pData),y
.9 rts
*---------------------------------------
SYM.UpdateGlobal >PUSHB.G SYM.hGlobals
>PUSHW.G ASM.SYM.ID
SYM.LookupGlobal >PUSHB.G SYM.hGlobals
>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
>SYSCALL SListUpdateByID

View File

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

View File

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