Kernel 0.9.1 : ASM rewrite....Symbols DB

This commit is contained in:
Rémy GIBERT 2018-01-23 16:52:22 +00:00
parent c9a37c4fad
commit f2cbecc25f
9 changed files with 90 additions and 107 deletions

Binary file not shown.

Binary file not shown.

View File

@ -2,15 +2,15 @@ NEW
PREFIX /A2OSX.BUILD PREFIX /A2OSX.BUILD
AUTO 4,1 AUTO 4,1
*--------------------------------------- *---------------------------------------
DIR.Init lda #$00 DIR.Init lda #$80
ldy #ASM.LI.ON
sta (pData),y
lda #0
ldy #ASM.LI.CON ldy #ASM.LI.CON
sta (pData),y sta (pData),y
ldy #ASM.LI.XON ldy #ASM.LI.XON
sta (pData),y sta (pData),y
lda #$80
ldy #ASM.LI.ON
sta (pData),y
rts rts
*--------------------------------------- *---------------------------------------
DIR.AC clc DIR.AC clc
@ -172,14 +172,13 @@ DIR.EP ldy #ASM.PH.ON
clc clc
rts rts
.9 lda #ERR.INV.DIRECTIVE .9 lda #ERR.INV.DIR
sec sec
rts rts
*--------------------------------------- *---------------------------------------
DIR.EQ jsr SRC.GetNextCharNB DIR.EQ jsr SRC.GetNextCharNB
bcs .99 bcs .99
>DEBUG
jsr EXP.Eval jsr EXP.Eval
bcs .9 bcs .9
@ -207,7 +206,7 @@ DIR.FI ldy #ASM.DO.Count
.1 clc .1 clc
rts rts
.99 lda #ERR.INV.DIRECTIVE .99 lda #ERR.INV.DIR
sec sec
rts rts
*--------------------------------------- *---------------------------------------
@ -268,6 +267,7 @@ DIR.LI.OFF ldy #ASM.LI.ON
DIR.LI.APPLY lsr DIR.LI.APPLY lsr
sta (pData),y sta (pData),y
clc
rts rts
DIR.LI.9 lda #ERR.SYNTAX.ERROR DIR.LI.9 lda #ERR.SYNTAX.ERROR
@ -282,7 +282,7 @@ DIR.MA jsr SRC.GetNextCharNB
jsr SRC.PrintLine jsr SRC.PrintLine
lda (ZPLineBuf) lda SRC.GetChar
beq .1 beq .1
cmp #'*' Comment? cmp #'*' Comment?
@ -392,7 +392,7 @@ DIR.PH ldy #ASM.PH.ON
jmp DIR.OR jmp DIR.OR
.9 lda #ERR.INV.DIRECTIVE .9 lda #ERR.INV.DIR
sec sec
rts rts
*--------------------------------------- *---------------------------------------

View File

@ -14,8 +14,8 @@ EXP.Eval stz EXP.Operator
stz EXP.Modifier stz EXP.Modifier
lda (ZPLinePtr) jsr SRC.GetChar
beq EXP.Eval.Missing bcs EXP.Eval.Missing
jsr SRC.IsMODReserved jsr SRC.IsMODReserved
bcs EXP.Eval.Next1 bcs EXP.Eval.Next1
@ -133,7 +133,7 @@ EXP.EvalOperator lda EXP.Operator
jsr EXP.Compute jsr EXP.Compute
bcs EXP.EvalExitRTS bcs EXP.EvalExitRTS
.7 jsr SRC.GetNextChar .7 jsr SRC.GetChar
bcs EXP.EvalExitOK bcs EXP.EvalExitOK
cmp #' ' cmp #' '

View File

@ -2,9 +2,7 @@ NEW
PREFIX /A2OSX.BUILD PREFIX /A2OSX.BUILD
AUTO 4,1 AUTO 4,1
*--------------------------------------- *---------------------------------------
SRC.PrintLine bra .8 SRC.PrintLine >LDA.G ASM.MACRO.ON
>LDA.G ASM.MACRO.ON
bpl .1 bpl .1
>LDA.G ASM.LI.CON >LDA.G ASM.LI.CON
@ -29,10 +27,8 @@ SRC.PrintLineErr >PUSHW ZPLineBuf
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
bcs .9 bcs .9
lda ZPLinePtr ldx ZPLinePtr
sec cpx ZPLineBuf
sbc ZPLineBuf
tax
beq .4 beq .4
.3 phx .3 phx
@ -41,6 +37,7 @@ SRC.PrintLineErr >PUSHW ZPLineBuf
plx plx
bcs .9 bcs .9
dex dex
cpx ZPLineBuf
bne .3 bne .3
.4 lda #'^' .4 lda #'^'
@ -56,60 +53,54 @@ SRC.PrintLineErr >PUSHW ZPLineBuf
.9 rts .9 rts
*--------------------------------------- *---------------------------------------
SRC.ParseLine lda (ZPLineBuf) SRC.ParseLine lda #0
tax
beq .1
cmp #'*' Comment?
beq .1
cmp #';' Comment?
beq .1
ldy #ASM.DO.ON
lda (pData),y
bne .1
lda #0
>STA.G SYM.bGlobalUpdate >STA.G SYM.bGlobalUpdate
cpx #' ' no label...go scan dir/opcode jsr SRC.GetChar
beq .4 bcs .8
cpx #'.' local symbol? cmp #'*' Comment?
beq .8
cmp #';' Comment?
beq .8
cmp #' ' no label...go scan dir/opcode
beq SRC.ParseLine.DirOp
cmp #'.' local symbol?
bne .2 bne .2
>DEBUG
jsr SRC.GetNextChar skip '.'
bcs SRC.ParseLine.Inv
jsr SRC.GetNextChar
bcs SRC.ParseLine.InvLbl
jsr SRC.GetDecimal jsr SRC.GetDecimal
bcs SRC.ParseLine.Inv bcs SRC.ParseLine.InvLbl
lda SRC.ACC+1 lda SRC.ACC+1
ora SRC.ACC+2 ora SRC.ACC+2
ora SRC.ACC+3 ora SRC.ACC+3
bne SRC.ParseLine.Inv Max .255 bne SRC.ParseLine.InvLbl Max .255
lda SRC.ACC lda SRC.ACC
beq SRC.ParseLine.Inv .0 is not allowed beq SRC.ParseLine.InvLbl .0 is not allowed
jsr SYM.AddLocal jsr SYM.AddLocal
bra .3 bra .3
.1 clc .8 clc
rts rts
.2 jsr SYM.AddGlobalPC .2 jsr SYM.AddGlobalPC
.3 bcs SRC.ParseLine.Err .3 bcs SRC.ParseLine.Err
.4 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
cmp #'.' cmp #'.'
bne .5 bne .5
jsr SRC.GetNextChar Skip . jsr SRC.GetNextChar
bcs SRC.ParseLine.InvDir
jsr SRC.ParseLine.Dir jsr SRC.ParseLine.Dir
bcs SRC.ParseLine.Err bcs SRC.ParseLine.Err
@ -150,7 +141,8 @@ SRC.ParseLine.Ok >LDA.G SYM.bGlobalUpdate
.8 clc .8 clc
rts rts
SRC.ParseLine.Inv lda #ERR.INV.LABEL SRC.ParseLine.InvLbl
lda #ERR.INV.LABEL
SRC.ParseLine.Err sec SRC.ParseLine.Err sec
rts rts
@ -158,27 +150,18 @@ SRC.ParseLine.Redef lda #ERR.SYMBOL.REDEFINE
sec sec
rts rts
SRC.ParseLine.SymR lda #ERR.RANGE SRC.ParseLine.InvDir
lda #ERR.INV.DIR
sec sec
rts rts
*--------------------------------------- *---------------------------------------
SRC.ParseLine.SymP jsr SRC.GetNextChar
bcs SRC.ParseLine.Inv
jsr SRC.GetDecimal
bcs SRC.ParseLine.Inv
jmp SYM.AddPrivate
*---------------------------------------
SRC.ParseLine.Dir >LDYA L.T.DIRECTIVES SRC.ParseLine.Dir >LDYA L.T.DIRECTIVES
jsr SRC.GetKeyword jsr SRC.GetKeyword
bcs .9 bcs SRC.ParseLine.InvDir
jmp (J.DIRECTIVES,x) jmp (J.DIRECTIVES,x)
.9 lda #ERR.INV.DIRECTIVE
sec
rts
*--------------------------------------- *---------------------------------------
SRC.ParseLine.Exec.Macro SRC.ParseLine.Exec.Macro
clc clc
@ -397,13 +380,13 @@ SRC.ParseLine.AM stz SRC.AM.ID
sec sec
.99 rts .99 rts
*--------------------------------------- *---------------------------------------
SRC.GetDecimal stz SRC.ACC+1 SRC.GetDecimal jsr SRC.GetChar
beq .99
stz SRC.ACC+1
stz SRC.ACC+2 stz SRC.ACC+2
stz SRC.ACC+3 stz SRC.ACC+3
lda (ZPLinePtr)
beq .99
jsr SRC.IsDigit10 jsr SRC.IsDigit10
bcs .99 bcs .99
@ -454,13 +437,13 @@ SRC.GetDecimal stz SRC.ACC+1
sec sec
rts rts
*--------------------------------------- *---------------------------------------
SRC.GetHex stz SRC.ACC+1 SRC.GetHex jsr SRC.GetNextChar skip '$'
bcs .99
stz SRC.ACC+1
stz SRC.ACC+2 stz SRC.ACC+2
stz SRC.ACC+3 stz SRC.ACC+3
jsr SRC.GetNextChar
bcs .99
jsr SRC.IsDigit16 jsr SRC.IsDigit16
bcs .99 bcs .99
@ -501,15 +484,13 @@ SRC.GetHex stz SRC.ACC+1
sec sec
rts rts
*--------------------------------------- *---------------------------------------
SRC.GetOctal stz SRC.ACC+1 SRC.GetOctal jsr SRC.GetNextChar skip '&'
bcs .99
stz SRC.ACC+1
stz SRC.ACC+2 stz SRC.ACC+2
stz SRC.ACC+3 stz SRC.ACC+3
jsr SRC.GetNextChar
bcs .99
lda (ZPLinePtr)
beq .99
jsr SRC.IsDigit8 jsr SRC.IsDigit8
bcs .99 bcs .99
@ -559,13 +540,13 @@ SRC.GetOctal stz SRC.ACC+1
sec sec
rts rts
*--------------------------------------- *---------------------------------------
SRC.GetBinary stz SRC.ACC+1 SRC.GetBinary jsr SRC.GetNextChar skip '%'
bcs .99
stz SRC.ACC+1
stz SRC.ACC+2 stz SRC.ACC+2
stz SRC.ACC+3 stz SRC.ACC+3
jsr SRC.GetNextChar
bcs .99
cmp #'1' cmp #'1'
beq .10 beq .10
@ -748,7 +729,7 @@ SRC.IsDigit8 cmp #'0'
.9 sec .9 sec
rts rts
*--------------------------------------- *---------------------------------------
SRC.GetNextCharNB jsr SRC.GetNextCharUC SRC.GetNextCharNB jsr SRC.GetNextChar
bcs .9 bcs .9
cmp #' ' cmp #' '
beq SRC.GetNextCharNB beq SRC.GetNextCharNB
@ -769,24 +750,24 @@ SRC.GetNextCharUC jsr SRC.GetNextChar
.9 rts .9 rts
*--------------------------------------- *---------------------------------------
SRC.GetNextChar lda (ZPLinePtr) SRC.GetNextChar lda (ZPLinePtr)
beq .9 beq SRC.GetChar.ERR
cmp #$0D cmp #$0D
beq .9 beq SRC.GetChar.ERR
inc ZPLinePtr inc ZPLinePtr
bne .8 bne SRC.GetChar
inc ZPLinePtr+1 inc ZPLinePtr+1
.8 lda (ZPLinePtr) SRC.GetChar lda (ZPLinePtr)
beq .9 beq SRC.GetChar.ERR
cmp #$0D cmp #$0D
beq .9 beq SRC.GetChar.ERR
clc clc
rts rts
.9 sec SRC.GetChar.ERR sec
rts rts
*--------------------------------------- *---------------------------------------
SRC.ACC10 lda SRC.ACC ACC*2-> ACC & ACCTMP SRC.ACC10 lda SRC.ACC ACC*2-> ACC & ACCTMP

View File

@ -45,7 +45,6 @@ SYM.Dump >LDYA L.MSG.SYMBOLS
.1 >PUSHB.G SYM.hGlobals .1 >PUSHB.G SYM.hGlobals
>PUSHW ZPLinePtr >PUSHW ZPLinePtr
>PUSHW ZPTmpBuf >PUSHW ZPTmpBuf
>SYSCALL SListGetByID >SYSCALL SListGetByID
bcs .8 bcs .8
>STYA ZPLinePtr >STYA ZPLinePtr

View File

@ -38,13 +38,12 @@ ERR.INV.ARGS .EQ $80
ERR.SRC.INV.TYPE .EQ $90 ERR.SRC.INV.TYPE .EQ $90
ERR.SRC.TOO.MANY.IN .EQ $91 ERR.SRC.TOO.MANY.IN .EQ $91
ERR.SRC.UNEXP.EOF .EQ $92 ERR.SRC.UNEXP.EOF .EQ $92
ERR.OOM .EQ $93
ERR.SYNTAX.ERROR .EQ $A0 ERR.SYNTAX.ERROR .EQ $A0
ERR.SYM.TOO.LONG .EQ $A1 ERR.SYM.TOO.LONG .EQ $A1
ERR.VAL.TOO.BIG .EQ $A2 ERR.VAL.TOO.BIG .EQ $A2
ERR.LINE.TOO.LONG .EQ $A3 ERR.LINE.TOO.LONG .EQ $A3
ERR.INV.LABEL .EQ $A4 ERR.INV.LABEL .EQ $A4
ERR.INV.DIRECTIVE .EQ $A5 ERR.INV.DIR .EQ $A5
ERR.INV.OPCODE .EQ $A6 ERR.INV.OPCODE .EQ $A6
ERR.INV.AM.SYN .EQ $A7 ERR.INV.AM.SYN .EQ $A7
ERR.INV.AM.4.OC .EQ $A8 ERR.INV.AM.4.OC .EQ $A8
@ -247,6 +246,7 @@ CS.RUN >SYSCALL GetChar
bne .1 bne .1
inc inc
sta (pData),y sta (pData),y
jsr DIR.Init Reset
clc clc
rts rts
@ -276,6 +276,9 @@ CS.RUN >SYSCALL GetChar
>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
@ -373,7 +376,7 @@ MSG.PASS >CSTR "Pass:#%d\r\n"
MSG.SRC.FILE >CSTR "Reading SRC File:%s\r\n" MSG.SRC.FILE >CSTR "Reading SRC File:%s\r\n"
MSG.OBJ.FILE >CSTR "Writing OBJ File:%s, Type=%02x\r\n" MSG.OBJ.FILE >CSTR "Writing OBJ File:%s, Type=%02x\r\n"
MSG.T.FILE >CSTR "Loading CPU File:%s\r\n" MSG.T.FILE >CSTR "Loading CPU File:%s\r\n"
MSG.SRCLINE >CSTR "%H: %05D-%s\r\n" 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"
@ -393,7 +396,6 @@ EXP.Modifier .BS 1
SRC.LINENUM .BS 2 SRC.LINENUM .BS 2
SRC.LinePtrSave .BS 2 SRC.LinePtrSave .BS 2
SRC.Directive.ID .BS 1
SRC.Keyword.ID .BS 1 SRC.Keyword.ID .BS 1
SRC.ACC .BS 4 SRC.ACC .BS 4
SRC.ACCTMP .BS 4 SRC.ACCTMP .BS 4

View File

@ -8,8 +8,9 @@ AUTO 4,1
*-------------------------------------- *--------------------------------------
.INB /A2OSX.BUILD/INC/MACROS.I .INB /A2OSX.BUILD/INC/MACROS.I
.INB /A2OSX.BUILD/INC/A2OSX.I .INB /A2OSX.BUILD/INC/A2OSX.I
.INB /A2OSX.BUILD/INC/GUI.I
.INB /A2OSX.BUILD/INC/LIBGUI.I .INB /A2OSX.BUILD/INC/LIBGUI.I
.INB /A2OSX.BUILD/X.FNT.I .INB /A2OSX.BUILD/ROOT/X.FNT.I
*-------------------------------------- *--------------------------------------
ZPPTR1 .EQ ZPBIN ZPPTR1 .EQ ZPBIN
ZPInputBufPtr .EQ ZPBIN+2 ZPInputBufPtr .EQ ZPBIN+2
@ -807,7 +808,7 @@ CS.QUIT >LDA.G hOutPutBuf
*-------------------------------------- *--------------------------------------
CS.END CS.END
*-------------------------------------- *--------------------------------------
.INB /A2OSX.BUILD/X.TWIST.G .INB /A2OSX.BUILD/ROOT/X.TWIST.G
*-------------------------------------- *--------------------------------------
OptionList >PSTR "NnVv" OptionList >PSTR "NnVv"
OptionVars .DA #bNoShrink,#bNoShrink,#bVerbose,#bVerbose OptionVars .DA #bNoShrink,#bNoShrink,#bVerbose,#bVerbose
@ -846,5 +847,5 @@ DS.END
.ED .ED
*-------------------------------------- *--------------------------------------
MAN MAN
SAVE /A2OSX.BUILD/FNT2FON.S SAVE /A2OSX.BUILD/ROOT/FNT2FON.S
ASM ASM

View File

@ -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
@ -83,7 +83,6 @@ 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 bcs .9
@ -93,8 +92,8 @@ SLIST.GetByID jsr SLIST.Select
jsr MEM.SetDataByteY jsr MEM.SetDataByteY
.1 iny .1 jsr SLIST.GetBlockByte
jsr SLIST.GetBlockByte iny
jsr MEM.SetDataByteY jsr MEM.SetDataByteY
dex dex
bne .1 bne .1
@ -103,16 +102,17 @@ SLIST.GetByID jsr SLIST.Select
tax tax
iny
jsr MEM.SetDataByteY jsr MEM.SetDataByteY
.2 iny .2 jsr SLIST.GetBlockByte
jsr SLIST.GetBlockByte iny
jsr MEM.SetDataByteY jsr MEM.SetDataByteY
dex dex
bne .2 bne .2
ldy SLIST.IndexOfs lda SLIST.IndexOfs
lda SLIST.BlockOfs ldy SLIST.BlockOfs
clc clc
rts rts
@ -180,15 +180,15 @@ SLIST.Free.A sta .8+1
SLIST.Select jsr K.GetMemPtr.A SLIST.Select jsr K.GetMemPtr.A
>STYA ZPSListIndex >STYA ZPSListIndex
ldy ZPSListKey ldy ZPSListKey+1
lda (ZPSListIndex),y sty SLIST.IndexOfs
sta SLIST.IndexOfs lda (ZPSListIndex),y
jsr K.GetMemPtr.A jsr K.GetMemPtr.A
>STYA ZPSListBlock >STYA ZPSListBlock
lda ZPSListKey+1 lda ZPSListKey
sta SLIST.BlockOfs sta SLIST.BlockOfs
rts rts
*-------------------------------------- *--------------------------------------