Kernel 0.9.1 : ASM, Local SYM ok, MACROS in progress

This commit is contained in:
Rémy GIBERT 2018-04-06 16:10:02 +01:00
parent 4358169b40
commit 79c593f907
12 changed files with 520 additions and 244 deletions

View File

@ -15,21 +15,21 @@ Multi-CPU macro assembler based on S-C MASM 3.0 dialect
| .BS | Block Storage | S-C,A2osX | Working | | |
| .DA | Data | S-C,A2osX | Working | | |
| .DO | conditional start | S-C,A2osX | Working | | |
| .DU,.DUMMY | begin DUmmy section | S-C,A2osX | In Progress | | |
| .ED | End Dmmy section | S-C,A2osX | In Progress | | |
| .DA | | S-C,A2osX | In Progress | | |
| .DU,.DUMMY | begin DUmmy section | S-C,A2osX | Working | | |
| .ED | End Dmmy section | S-C,A2osX | Working | | |
| .DA | DAta | S-C,A2osX | Working | | |
| .ELSE | conditional ELSE | S-C,A2osX | Working | | |
| .EM | End Macro | S-C,A2osX | In Progress | | |
| .EM | End Macro | S-C,A2osX | Working | | |
| .EN | ENd of source code | S-C,A2osX | In Progress | | |
| .EP | End Phase| S-C,A2osX | In Progress | | |
| .EQ | EQuate | S-C,A2osX | In Progress | | |
| .EP | End Phase | S-C,A2osX | Working | | |
| .EQ | EQuate | S-C,A2osX | Working | | |
| .FIN | conditional end| S-C,A2osX | Working | | |
| .PH | PHase start| S-C,A2osX | Working | | |
| .HS | Hex String | S-C,A2osX | Working | `HS FE1A78` delimiter allowed : `HS 00.11,22` | |
| .IN,.INB,.INBx | | S-C,A2osX | Working | | |
| .LI,.LIST | | S-C,A2osX | Working | | |
| .MA | MAcro deffinition | S-C,A2osX | Working | | |
| .OP | OPCode | S-C,A2osX | Working | `.OP cpu` where cpu is one of 6502,65C02,65R02,65816,Z80,S16 | |
| .OP | OPCode | S-C,A2osX | Working | `.OP cpu` where cpu is one of 6502,65C02,65R02,65816,Z80,SW16 | |
| .OR | ORigin | S-C,A2osX | Working | | |
| .PG | PaGe control | S-C,A2osX | IGNORED | | |
| .PH | PHase | S-C,A2osX | Working | | |

Binary file not shown.

Binary file not shown.

View File

@ -180,7 +180,7 @@ DIR.DA jsr SRC.GetNextCharNB
*---------------------------------------
DIR.DO >LDA.G ASM.DO.StackPtr
inc
cmp #SRC.DO.MAXDEPTH
cmp #DO.MAXDEPTH
bcs .98
jsr SRC.GetNextCharNB
@ -202,7 +202,7 @@ DIR.DO >LDA.G ASM.DO.StackPtr
lda #$ff
.1 sta (pData),y
.1 sta (pData),y
lda #$FF
>STA.G ASM.DO.ON
clc
@ -212,10 +212,36 @@ DIR.DO >LDA.G ASM.DO.StackPtr
sec
.99 rts
*---------------------------------------
DIR.DU clc
DIR.DU >LDA.G ASM.DU.ON
bmi DIR.DU.ERR
lda #$80
sta (pData),y
ldy #ASM.PC.DU
jsr DIR.SavePC
clc
rts
DIR.DU.ERR lda #ERR.INV.DIR
sec
rts
*---------------------------------------
DIR.ED clc
DIR.ED >LDA.G ASM.DU.ON
bpl DIR.DU.ERR
lda #0
sta (pData),y
ldy #ASM.PC.DU
jsr DIR.RestorePC
clc
rts
.9 lda #ERR.INV.DIR
sec
rts
*---------------------------------------
DIR.EL >LDA.G ASM.DO.StackPtr
@ -231,7 +257,6 @@ DIR.EL >LDA.G ASM.DO.StackPtr
clc
rts
.9 lda #ERR.ELSE.WITHOUT.DO
sec
rts
@ -243,30 +268,15 @@ DIR.EM lda #ERR.MACRO.INV.DEF
DIR.EN clc
rts
*---------------------------------------
DIR.EP ldy #ASM.PH.ON
lda (pData),y
DIR.EP >LDA.G ASM.PH.ON
bpl .9
lda #0
sta (pData),y
ldy #ASM.PC.PH+3
ldx #3
.1 lda (pData),y
pha
dey
dex
bpl .1
ldy #ASM.PC
ldx #3
.2 pla
sta (pData),y
iny
dex
bpl .2
ldy #ASM.PC.PH
jsr DIR.RestorePC
clc
rts
@ -274,12 +284,15 @@ DIR.EP ldy #ASM.PH.ON
sec
rts
*---------------------------------------
DIR.SE lda #SYMG.F.RW
sta SRC.ACC.F
DIR.SE sec
.HS 90 BCC
*---------------------------------------
DIR.EQ lda (ZPGlobalBuf)
DIR.EQ clc
lda (ZPGlobalBuf)
beq .99
ror
>STA.G OUT.bEquate
jsr SRC.GetNextCharNB
@ -291,11 +304,7 @@ DIR.EQ lda (ZPGlobalBuf)
jsr SYM.Acc2Global
bcs .9
jsr SYM.FlushGlobal
bcs .9
lda #0
sta (ZPGlobalBuf)
rts
jmp SYM.FlushGlobal
.99 lda #ERR.SYNTAX.ERROR
sec
@ -407,7 +416,6 @@ DIR.IN jsr SRC.GetNextCharNB
plp
rts
.9 lda #ERR.SYNTAX.ERROR
sec
rts
@ -475,7 +483,7 @@ DIR.LI.APPLY lda #0
sta (pData),y
rts
*---------------------------------------
DIR.MA >LDA.G MAC.bAdd
DIR.MA >LDA.G ASM.MA.ON
bmi .9
>LDA.G ASM.PASS If Pass#2, ignore
@ -484,17 +492,20 @@ DIR.MA >LDA.G MAC.bAdd
jsr SRC.GetNextCharNB
beq DIR.OP.SYNERR
jsr SYM.GetName
bcs .99
jsr MAC.New
.8 lda #$ff
>STA.G MAC.bAdd
>STA.G ASM.MA.ON
clc
rts
.9 lda #ERR.MACRO.INV.DEF
sec
rts
.99 rts
*---------------------------------------
DIR.OP jsr SRC.GetNextCharNB
bcs DIR.OP.SYNERR
@ -527,30 +538,14 @@ DIR.OR jsr SRC.GetNextCharNB
DIR.PG clc
rts
*---------------------------------------
DIR.PH ldy #ASM.PH.ON
lda (pData),y
DIR.PH >LDA.G ASM.PH.ON
bmi .9
lda #$80
sta (pData),y
ldy #ASM.PC+3
ldx #3
.1 lda (pData),y
pha
dey
dex
bpl .1
ldy #ASM.PC.PH
ldx #3
.2 pla
sta (pData),y
iny
dex
bpl .2
jsr DIR.SavePC
jmp DIR.OR
@ -570,6 +565,46 @@ DIR.TI clc
DIR.US clc
rts
*---------------------------------------
DIR.SavePC ldx #3
phy
ldy #ASM.PC+3
.1 lda (pData),y
pha
dey
dex
bpl .1
ply
ldx #3
.2 pla
sta (pData),y
iny
dex
bpl .2
rts
*---------------------------------------
DIR.RestorePC ldx #3
.1 lda (pData),y
pha
iny
dex
bpl .1
ldy #ASM.PC+3
ldx #3
.2 pla
sta (pData),y
dey
dex
bpl .2
rts
*---------------------------------------
MAN
SAVE /A2OSX.BUILD/BIN/DEV/ASM.S.DIR
LOAD /A2OSX.BUILD/BIN/DEV/ASM.S

View File

@ -51,7 +51,7 @@ EXP.Eval.Next lda #2
cmp #'.' Local Label?
bne .12
jsr EXP.GetLSymIDInAcc
jsr EXP.GetSymL
bcs .14
jmp EXP.EvalOperator
@ -176,17 +176,16 @@ EXP.EvalOperator
txa
>STA.G EXP.Operator
ldx #5
ldx #4
.8 lda SRC.ACC.F,x
sta SRC.ARG.F,x
.8 lda SRC.ACC.SIZE,x
sta SRC.ARG.SIZE,x
dex
bpl .8
jmp EXP.Eval.Next0
*---------------------------------------
EXP.GetLSymIDInAcc
jsr SRC.GetNextChar
EXP.GetSymL jsr SRC.GetNextChar
bcs .9
jsr SRC.GetDecimal
@ -199,12 +198,18 @@ EXP.GetLSymIDInAcc
beq EXP.EvalExitSYN .0 is not allowed
jsr SYM.LookupLocal
bcs EXP.EvalExitUND
bcc .8
>LDA.G ASM.PASS pass#2?
bne EXP.EvalExitUND
lda #0 Mark ACC as pending
sta SRC.ACC.SIZE
clc
rts
.9 lda #ERR.SYNTAX.ERROR
sec
rts
.8 rts
*---------------------------------------
EXP.GetSymG jsr SYM.LookupGlobal
bcs .2
@ -214,10 +219,10 @@ EXP.GetSymG jsr SYM.LookupGlobal
clc
rts
.2 >LDA.G ASM.PASS pass#2?
bne .99 yes, undefined symbol
.2 >LDA.G ASM.PASS pass#2?
bne EXP.EvalExitUND yes, undefined symbol
lda #0 Mark ACC as pending
lda #0 Mark ACC as pending
sta SRC.ACC.SIZE
.3 jsr SRC.GetNextChar
@ -237,33 +242,6 @@ EXP.GetSymG jsr SYM.LookupGlobal
sec
.9 rts
*---------------------------------------
EXP.SetAccA sta SRC.ACC
stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
lda #1
sta SRC.ACC.SIZE
rts
*---------------------------------------
EXP.Compute lda SRC.ACC.F
and SRC.ARG.F
and #SYMG.F.RESOLVED
beq .1
asl
tax
jmp (J.EXP.OP-2,x)
.1 >LDA.G ASM.PASS
beq .8
lda #ERR.UNDEF.SYMBOL
sec
rts
.8 clc
rts
*---------------------------------------
EXP.MOD.8.3 lda SRC.ACC+2
bra EXP.MOD.8
EXP.MOD.8.2 lda SRC.ACC+1
@ -281,6 +259,25 @@ EXP.MOD.32 lda #4
clc
rts
*---------------------------------------
EXP.Compute ldx SRC.ACC.SIZE
beq .1
ldx SRC.ARG.SIZE
beq .1
asl
tax
jmp (J.EXP.OP-2,x)
.1 >LDA.G ASM.PASS
beq .8
lda #ERR.UNDEF.SYMBOL
sec
rts
.8 clc
rts
*---------------------------------------
EXP.OP.EOR ldx #3
.1 lda SRC.ARG,x
@ -308,8 +305,12 @@ EXP.OP.AND ldx #3
bpl .1
rts
*---------------------------------------
EXP.OP.LOW clc
rts
EXP.OP.LOW jsr EXP.OP.SUB
lda #0
rol
jmp EXP.SetAccA
*---------------------------------------
EXP.OP.EQU ldx #0 ARG-ACC->ACC
ldy #4
@ -334,13 +335,17 @@ EXP.OP.EQU ldx #0 ARG-ACC->ACC
.9 rts
*---------------------------------------
EXP.OP.GRT
clc
rts
EXP.OP.GRT jsr EXP.OP.SUB
lda #0
rol
eor #1
jmp EXP.SetAccA
*---------------------------------------
EXP.OP.ADD ldx #0 ARG-ACC->ACC
ldy #4
clc
.1 lda SRC.ARG,x
@ -357,7 +362,7 @@ EXP.OP.ADD ldx #0 ARG-ACC->ACC
*---------------------------------------
EXP.OP.SUB ldx #0 ARG-ACC->ACC
ldy #4
sec
.1 lda SRC.ARG,x
@ -382,6 +387,15 @@ EXP.OP.DIV
clc
rts
*---------------------------------------
EXP.SetAccA sta SRC.ACC
stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
lda #1
sta SRC.ACC.SIZE
clc
rts
*---------------------------------------
MAN
SAVE /A2OSX.BUILD/BIN/DEV/ASM.S.EXP
LOAD /A2OSX.BUILD/BIN/DEV/ASM.S

View File

@ -111,7 +111,7 @@ FIO.OpenFile >STYA ZPPtr1
ldy #SRC.COUNT
lda (pData),y
cmp #SRC.IN.MAXDEPTH
cmp #IN.MAXDEPTH
bne .1
lda #ERR.SRC.TOO.MANY.IN

View File

@ -5,7 +5,7 @@ AUTO 4,1
MAC.Init >SYSCALL SListNew
bcs .9
>STA.G MAC.hMacros
>STA.G MAC.hMacroList
>LDYAI 256
>SYSCALL GetMem.YA
@ -13,16 +13,43 @@ MAC.Init >SYSCALL SListNew
>STYA ZPMacroBuf
txa
>STA.G MAC.hBuf
>STA.G MAC.hMacroBuf
>SYSCALL SListNew
bcs .9
>STA.G MAC.hCtxList
>LDYAI 256
>SYSCALL GetMem.YA
bcs .9
>STYA ZPCtxBuf
txa
>STA.G MAC.hCtxBuf
.9 rts
*---------------------------------------
MAC.Quit >LDA.G MAC.hBuf
MAC.Reset >STZ.G MAC.CtxID
iny
sta (pData),y
rts
*---------------------------------------
MAC.Quit >LDA.G MAC.hCtxBuf
beq .1
>SYSCALL FreeMem.A
.1 >LDA.G MAC.hMacros
.1 >LDA.G MAC.hCtxList
beq .2
>SYSCALL SListFree.A
.2 >LDA.G MAC.hMacroBuf
beq .3
>SYSCALL FreeMem.A
.3 >LDA.G MAC.hMacroList
beq .8
>SYSCALL SListFree.A
@ -43,8 +70,8 @@ MAC.AddChar >LDA.G ASM.PASS If Pass#2, ignore
tax
lda (ZPMacroBuf)
* cmp #254
* beq .9 CS if EQ
cmp #254
beq .9 CS if EQ
inc
sta (ZPMacroBuf)
@ -74,11 +101,36 @@ MAC.AddChar >LDA.G ASM.PASS If Pass#2, ignore
MAC.Store >LDA.G ASM.PASS If Pass#2, ignore
bne .8
lda (ZPMacroBuf)
beq .8
>PUSHB.G MAC.hMacroList
>PUSHW ZPNameBuf
>PUSHW ZPMacroBuf
>SYSCALL SListAdd
rts
.8 clc
rts
*---------------------------------------
MAC.Lookup >PUSHB.G MAC.hMacroList
>PUSHW ZPLinePtr
>PUSHW ZPMacroBuf
>SYSCALL SListLookup
bcs .9
adc ZPLinePtr
sta ZPLinePtr
bcc .8
inc ZPLinePtr+1
clc
.8
.9 rts
*---------------------------------------
MAC.NewOrGetCtx
*---------------------------------------
*---------------------------------------
MAN
SAVE /A2OSX.BUILD/BIN/DEV/ASM.S.MAC
LOAD /A2OSX.BUILD/BIN/DEV/ASM.S

View File

@ -85,7 +85,7 @@ OUT.PrintLineOn clc
>LDA.G ASM.LI.ON
bpl .9
>LDA.G MAC.bAdd MACRO Mode ?
>LDA.G ASM.MA.ON MACRO Mode ?
bpl .1
>LDA.G ASM.LI.MON
@ -177,7 +177,8 @@ OUT.Print1 >DEC.G OUT.LineCnt
lda #20
sta (pData),y
>DEBUG
lda #$80
>STA.G bPause
.8 rts
*---------------------------------------

View File

@ -21,7 +21,7 @@ SRC.ParseLine jsr OUT.Reset
lda (pData),y
beq .8
.1 >LDA.G MAC.bAdd
.1 >LDA.G ASM.MA.ON
bmi SRC.ParseLine.MACRO
jmp SRC.ParseLine.LABEL
@ -80,7 +80,7 @@ SRC.ParseLine.Macro
.22 jsr MAC.Store
bcs SRC.ParseLine.RTS
>STZ.G MAC.bAdd
>STZ.G ASM.MA.ON
.8 clc
rts
@ -208,10 +208,37 @@ SRC.ParseLine.Dir
jmp (J.DIRECTIVES,x)
*---------------------------------------
SRC.ParseLine.ExecMacro
jsr SRC.GetNextChar skip '>'
bcs .90
jsr MAC.Lookup
bcs .90
>LDA.G ASM.MA.StackPtr
cmp #MA.MAXDEPTH
beq .91
clc
adc #ASM.MA.StackPtr
tay
>INC.G ASM.MA.StackPtr
clc
rts
.90 lda #ERR.MACRO.INV
sec
rts
.91 lda #ERR.MACRO.INV
sec
rts
*---------------------------------------
SRC.ParseLine.OpCode
stz SRC.AM.StrBuf
@ -366,7 +393,7 @@ SRC.ParseLine.AMCheck
* >PUSHW L.SRC.AM.StrBuf
* >LDYA L.MSG.PSTRCRLF
* >SYSCALL PrintF.YA
* >DEBUG
lda SRC.AM.StrBuf
beq SRC.ParseLine.OPAMCheckFF
@ -424,7 +451,7 @@ SRC.ParseLine.OPAMCheck
.10 lda (ZPOpDefPtr)
.1 >CMP.G SRC.AMID
beq .3
beq SRC.ParseLine.Emit
ldy #1
lda (ZPOpDefPtr),y
@ -440,8 +467,9 @@ SRC.ParseLine.OPAMCheck
.99 lda #ERR.INV.AM.4.OC
sec
rts
.3 stz SRC.ACCTMP index in ACC
*---------------------------------------
SRC.ParseLine.Emit
stz SRC.ACCTMP index in ACC
ldy #1
lda (ZPOpDefPtr),y
@ -450,7 +478,8 @@ SRC.ParseLine.OPAMCheck
.4 lda (ZPOpDefPtr),y
cmp #'a
bcs .5
bcs .5 lowercase, go compute address
jsr SRC.IsDigit16
asl
asl
@ -469,10 +498,11 @@ SRC.ParseLine.OPAMCheck
iny
dec SRC.ACCTMP+1
bne .4
clc
rts
.5 bne .6
.5 bne .6 cmp #'a'....
ldx SRC.ACCTMP
inc SRC.ACCTMP
@ -480,28 +510,137 @@ SRC.ParseLine.OPAMCheck
bra .50
.6 cmp #'r
bne .99
bne .7
lda SRC.ACC.SIZE
beq .50 Emit 00 if pending symbol (pass #1)
jsr SRC.ComputeRel8
bcs .91
bra .50
.7 cmp #'l
bne .90
ldx SRC.ACCTMP
inc SRC.ACCTMP
lda ASM.PC,x
sec
sbc SRC.ACC,x
pha
lda SRC.ACC.SIZE
bne .71
jsr OUT.EmitByte Emit 00 00 if pending symbol (pass #1)
bcs .9
lda #0
bra .50
pla
.71 jsr SRC.ComputeRel16
bcs .91
lda SRC.ACC
jsr OUT.EmitByte
bcs .9
lda SRC.ACC+1
bra .50
.8 clc
.9 rts
.90 lda #ERR.INV.T.FILE
sec
rts
.91 lda #ERR.RANGE
sec
rts
*---------------------------------------
SRC.AddToBuf inc SRC.AM.StrBuf
ldy SRC.AM.StrBuf
sta SRC.AM.StrBuf,y
rts
*---------------------------------------
SRC.ComputeRel8 jsr SRC.ComputeRel
bcc .1
* positive : check 0<r<0000007F
lda SRC.ACC+3
ora SRC.ACC+2
ora SRC.ACC+1
bne .9
lda SRC.ACC
bmi .9
clc
rts
* negative : check FFFFFF80<r<FFFFFFFF
.1 lda SRC.ACC+3
and SRC.ACC+2
and SRC.ACC+1
inc
bne .9
lda SRC.ACC
bpl .9
clc
rts
.9 sec
rts
*---------------------------------------
SRC.ComputeRel16
jsr SRC.ComputeRel
bcc .1
* positive : check 0<r<00007FFF
lda SRC.ACC+3
ora SRC.ACC+2
bne .9
lda SRC.ACC+1
bmi .9
clc
rts
* negative : check FFFF8000<r<FFFFFFFF
.1 lda SRC.ACC+3
and SRC.ACC+2
inc
bne .9
lda SRC.ACC+1
bpl .9
clc
rts
.9 sec
rts
*---------------------------------------
SRC.ComputeRel phy
ldy #ASM.PC
clc
lda SRC.ACC
sbc (pData),y
sta SRC.ACC
iny
lda SRC.ACC+1
sbc (pData),y
sta SRC.ACC+1
iny
lda SRC.ACC+2
sbc (pData),y
sta SRC.ACC+2
iny
lda SRC.ACC+3
sbc (pData),y
sta SRC.ACC+3
ply
rts
*---------------------------------------
SRC.GetDecimal jsr SRC.GetChar
beq .99
@ -596,12 +735,7 @@ SRC.GetHex jsr SRC.GetNextChar skip '$'
sta SRC.ACC
bra .1
.8 lda #SYMG.F.RESOLVED
sta SRC.ACC.F
lda #2
sta SRC.ACC.SIZE
clc
.8 clc
rts
.9 lda #ERR.VAL.TOO.BIG

View File

@ -11,6 +11,10 @@ AUTO 4,1
* 2-5 : 32 bits Value
* 6+ : Local Symbols.....
*---------------------------------------
* Local Symbol Record: (5 bytes)
* 0 : Local ID (1->255)
* 1-4 : 32 bits Value (PC)
*---------------------------------------
SYM.Init >SYSCALL SListNew
bcs .9
@ -119,8 +123,7 @@ SYM.Dump stz ZPLinePtr
>LDYA L.MSG.PSTR
>SYSCALL PrintF.YA
bcs .9
>DEBUG
ldy #SYMG.SIZE-1
ldy #SYMG.SIZE
.4 tya
@ -142,7 +145,7 @@ SYM.Dump stz ZPLinePtr
pla
>PUSHA
phy
>LDYA L.MSG.PSTR
>LDYA L.MSG.LSYMBOL
>SYSCALL PrintF.YA
ply
bne .4
@ -167,7 +170,7 @@ SYM.NewGlobal jsr SYM.LookupGlobal Pass #1; try to add global...
jsr SYM.PC2Global A=PC Size
lda #SYMG.SIZE-1
lda #SYMG.SIZE
sta (ZPGlobalBuf)
clc
rts
@ -212,8 +215,7 @@ SYM.LookupGlobal
bcc .8
inc ZPLinePtr+1
clc
clc
.8
.9 rts
*---------------------------------------
@ -228,15 +230,19 @@ SYM.FlushGlobal lda (ZPGlobalBuf)
>PUSHW ZPNameBuf
>PUSHW ZPGlobalBuf
>SYSCALL SListAdd
rts
bra .3
.2 >PUSHW.G SYM.GlobalID
>PUSHW ZPGlobalBuf
>SYSCALL SListUpdateByID
.3 bcs .9
lda #0
sta (ZPGlobalBuf)
rts
.8 clc
rts
.9 rts
*---------------------------------------
SYM.GetName jsr SRC.GetChar
bcs .9
@ -295,7 +301,6 @@ SYM.PC2Global ldx #4
.4 txa
ora #SYMG.F.RESOLVED
ldy #SYMG.F
sta (ZPGlobalBuf),y
@ -303,112 +308,132 @@ SYM.PC2Global ldx #4
rts
*---------------------------------------
SYM.Acc2Global ldx #3
ldy #SYMG.V+3
SYM.Acc2Global ldx #4
ldy #SYMG.F+4
.1 lda SRC.ACC,x
.1 lda SRC.ACC.SIZE,x
sta (ZPGlobalBuf),y
dey
dex
bpl .1
lda SRC.ACC.SIZE
ora SRC.ACC.F
sta (ZPGlobalBuf),y
clc
rts
*---------------------------------------
SYM.Lookup2Acc ldy #SYMG.V+3
ldx #3
SYM.Lookup2Acc ldy #SYMG.F+4
ldx #4
.1 lda (ZPLookupBuf),y
sta SRC.ACC,x
sta SRC.ACC.SIZE,x
dey
dex
bpl .1
bne .1
lda (ZPLookupBuf),y
and #SYMG.F.SIZE
sta SRC.ACC.SIZE
lda (ZPLookupBuf),y
and #SYMG.F.SIZE^$ff
sta SRC.ACC.F
clc
rts
*---------------------------------------
* Local Symbol Record: (6 bytes)
* Local Symbol Record: (5 bytes)
* 0 : Local ID (1->255)
* 1 : Flags:
* b7=0=pending,1=resolved
* 2-5 : 32 bits Value (PC)
* 1-4 : 32 bits Value (PC)
*---------------------------------------
SYM.NewOrGetLocalA
tax Save ID
>LDA.G ASM.PASS
bne SYM.GetLocal Pass #2: should be already defined...
lda (ZPGlobalBuf) not in a global label
bne .1
lda #ERR.INV.LABEL
clc
rts
*---------------------------------------
SYM.AddLocal lda (ZPGlobalBuf)
.1 >LDA.G ASM.PASS
bne SYM.LookupLocal.1 Pass #2: should be already defined...
SYM.NewLocal jsr SYM.LookupLocal.1 Pass #1; try to add
bcc .9 Already Defined
lda (ZPGlobalBuf)
tay
clc
adc #SYML.SIZE
bcs .9
bcs .90
ldy #ASM.PC+4
.1 dey
lda (pData),y
pha
cpy #ASM.PC
bne .1
lda (ZPGlobalBuf)
tay
iny
txa Get Back ID
sta (ZPGlobalBuf),y
iny
phy
ldx #4
ldy #ASM.PC+3
.1 lda (pData),y
pha
dey
dex
bne .1
ldx #4
ply
.2 pla
sta (ZPGlobalBuf),y
iny
sta (ZPGlobalBuf),y
dex
bne .2
lda #0
sta (ZPGlobalBuf),y
tya
sta (ZPGlobalBuf)
* clc
clc
rts
.9 lda #ERR.TOO.MANY.LOCAL
.90 lda #ERR.TOO.MANY.LOCAL
* sec
rts
*---------------------------------------
SYM.GetLocal
.9 lda #ERR.SYMBOL.REDEF
sec
rts
*---------------------------------------
SYM.LookupLocal lda #2
sta SRC.ACC.SIZE
lda #$FF
sta SRC.ACC
sta SRC.ACC+1
SYM.LookupLocal tax
SYM.LookupLocal.1
ldy #SYMG.SIZE
tya
.1 cmp (ZPGlobalBuf)
beq .9 CS if =
txa
iny
cmp (ZPGlobalBuf),y
beq .2
tya
clc
adc #SYML.SIZE-1
tay
bcc .1
.9 lda #ERR.UNDEF.SYMBOL
* sec
rts
.2 ldx #0
.3 iny
lda (ZPGlobalBuf),y
sta SRC.ACC,x
inx
cpx #4
bne .3
clc
rts
*---------------------------------------
@ -428,14 +453,6 @@ SYM.LookupPrivate
clc
rts
*---------------------------------------
SYM.AddMacro
clc
rts
*---------------------------------------
SYM.LookupMacro
clc
rts
*---------------------------------------
MAN
SAVE /A2OSX.BUILD/BIN/DEV/ASM.S.SYM
LOAD /A2OSX.BUILD/BIN/DEV/ASM.S

View File

@ -17,37 +17,45 @@ ZPLinePtr .EQ ZPBIN+6
ZPNameBuf .EQ ZPBIN+8
ZPGlobalBuf .EQ ZPBIN+10
ZPLookupBuf .EQ ZPBIN+12
ZPMacroBuf .EQ ZPBIN+14
ZPTmpBuf .EQ ZPBIN+16
ZPMacroBuf .EQ ZPBIN+14
ZPCtxBuf .EQ ZPBIN+16
ZPAMPtr .EQ ZPBIN+18
ZPRPtr .EQ ZPBIN+20
ZPOpsPtr .EQ ZPBIN+22
ZPOpDefPtr .EQ ZPBIN+24
ZPTmpBuf .EQ ZPBIN+16
*---------------------------------------
SYMG.LEN .EQ 0
SYMG.F .EQ 1
SYMG.F.RESOLVED .EQ %10000000
SYMG.F.RW .EQ %01000000
SYMG.F.RW .EQ %10000000
SYMG.F.SIZE .EQ %00000111
SYMG.V .EQ 2
*
SYMG.SIZE .EQ 6
SYMG.SIZE .EQ 5
*---------------------------------------
SYML.ID .EQ 0
SYML.V .EQ 1
*
SYML.SIZE .EQ 5
*---------------------------------------
MCTX.LEN .EQ 0
MCTX.PTR .EQ 1
MCTX.ID .EQ 2
MCTX.ARGS .EQ 4
*---------------------------------------
ASM.T.AM .EQ 0
ASM.T.R .EQ 2
ASM.T.O .EQ 4
*---------------------------------------
SRC.DO.MAXDEPTH .EQ 8
SRC.IN.MAXDEPTH .EQ 7
DO.MAXDEPTH .EQ 8
IN.MAXDEPTH .EQ 7
MA.MAXDEPTH .EQ 8
*---------------------------------------
ERR.INV.ARGS .EQ $80
ERR.INV.T.FILE .EQ $81
ERR.SRC.INV.TYPE .EQ $90
ERR.SRC.TOO.MANY.IN .EQ $91
ERR.SRC.UNEXP.EOF .EQ $92
@ -71,6 +79,8 @@ ERR.MISSING.EXP .EQ $B0
ERR.EXP.SYN.ERROR .EQ $B1
ERR.MACRO.INV.DEF .EQ $E0
ERR.MACRO.TOO.BIG .EQ $E1
ERR.MACRO.INV .EQ $E2
ERR.MACRO.TOO.MANY .EQ $E3
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -235,25 +245,28 @@ CS.INIT ldy #S.PS.ARGC
.9 rts
*--------------------------------------
CS.RUN >SYSCALL GetChar
bcs .11 no char
bcs .13 no char
cmp #$03 Ctrl-C
beq .99 Abort....beq=CS
cmp #$13 Ctrl-S
cmp #$03 Ctrl-C
beq .99 Abort....beq=CS
cmp #$13 Ctrl-S
bne .11
ldy #bPause
lda (pData),y
>LDA.G bPause
eor #$ff
sta (pData),y
.11 ldy #bPause
lda (pData),y
bne .8
bpl .12
clc
rts
ldy #SRC.COUNT root file is already opened?
lda (pData),y
.13 >LDA.G bPause
bmi .8
.11 >STZ.G bPause
.12 >LDA.G SRC.COUNT root file is already opened?
bne .10
>LDA.G ASM.PASS
@ -272,10 +285,11 @@ CS.RUN >SYSCALL GetChar
jsr DIR.Reset
jsr SYM.Reset
jsr MAC.Reset
.10 jsr FIO.ReadLine
bcc .2
cmp #$4C End Of File?
cmp #$4C End Of File?
bne .9
jsr FIO.FileClose
@ -414,7 +428,7 @@ T.LI >PSTR "ON"
ASM..T. .AZ ".T."
ASM.6502 .AZ "6502"
MSG.HELP .AZ "A2osX-Macro Assembler (S-C MASM 3.0 Based)\r\nUsage : ASM <src file> [type TXT ($04) or S-C/BAS ($FA)]\r\n"
MSG.PASS .AZ "Pass:#%d\r\n"
MSG.PASS .AZ "*** Pass:#%d\r\n"
MSG.SRC.FILE .AZ "*** Reading SRC File:%s\r\n"
MSG.OBJ.FILE .AZ "*** Writing OBJ File:%s, Type=%02x\r\n"
MSG.T.FILE .AZ "*** Loading CPU File:%s\r\n"
@ -427,7 +441,7 @@ MSG.EQU1 .AZ " [ %h]"
MSG.EQU2 .AZ " [ %h%h]"
MSG.EQU3 .AZ " [ %h%h%h]"
MSG.EQU4 .AZ " [%h%h%h%h]"
MSG.LSYMBOL .AZ ", .%d %h%h%h%h"
MSG.LSYMBOL .AZ ", .%d=%h%h%h%h"
MSG.SRCLINE .AZ " %05D %s\r\n"
MSG.ERROR .AZ "*** Fatal Error $%h "
MSG.SYMBOLS .AZ "Symbol Table:\r\n"
@ -443,11 +457,9 @@ ASM.T.FILENAME .BS 65
FIO.Stat .BS S.STAT
SRC.ACC.F .BS 1
SRC.ACC.SIZE .BS 1
SRC.ACC .BS 4
SRC.ARG.F .BS 1
SRC.ARG.SIZE .BS 1
SRC.ARG .BS 4
@ -464,8 +476,8 @@ SRC.hLineBuf .BS 1
SRC.hTmpBuf .BS 1
SRC.COUNT .BS 1
SRC.hFILES .BS SRC.IN.MAXDEPTH
SRC.hFILETYPES .BS SRC.IN.MAXDEPTH
SRC.hFILES .BS IN.MAXDEPTH
SRC.hFILETYPES .BS IN.MAXDEPTH
SRC.LINENUM .BS 2
SRC.AMID .BS 1
@ -482,20 +494,29 @@ EXP.Modifier .BS 1
EXP.Prefix .BS 1
EXP.Operator .BS 1
ASM.T.hMem .BS 1
ASM.PASS .BS 1
ASM.DO.StackPtr .BS 1
ASM.DO.Stack .BS SRC.DO.MAXDEPTH
ASM.DO.ON .BS 1
ASM.DO.StackPtr .BS 1
ASM.DO.Stack .BS DO.MAXDEPTH
ASM.DU.ON .BS 1
ASM.PH.ON .BS 1
ASM.LI.ON .BS 1
ASM.LI.CON .BS 1
ASM.LI.MON .BS 1
ASM.LI.XON .BS 1
ASM.MA.ON .BS 1
ASM.MA.StackPtr .BS 1
ASM.MA.Stack .BS MA.MAXDEPTH
ASM.PC .BS 4
ASM.PC.PH .BS 4
ASM.PC.DU .BS 4
SYM.hGlobalList .BS 1
SYM.hNameBuf .BS 1
@ -506,9 +527,11 @@ SYM.hLookupBuf .BS 1
SYM.LocalID .BS 2
MAC.hMacros .BS 1
MAC.hBuf .BS 1
MAC.bAdd .BS 1
MAC.hMacroList .BS 1
MAC.hMacroBuf .BS 1
MAC.hCtxList .BS 1
MAC.hCtxBuf .BS 1
MAC.CtxID .BS 2
OUT.PC .BS 4
OUT.Buf .BS 4

View File

@ -89,7 +89,7 @@ BRK .DA BRK.E+1-*
BRK.E .HS 00
BRL .DA BRL.E+1-*
.DA #3,$$"BRL"
.DA #11,#4,$$"82rr"
.DA #11,#3,$$"82l"
BRL.E .HS 00
BVC .DA BVC.E+1-*
.DA #3,$$"BVC"
@ -295,7 +295,7 @@ PEI .DA PEI.E+1-*
PEI.E .HS 00
PER .DA PER.E+1-*
.DA #3,$$"PER"
.DA #11,#4,$$"62rr"
.DA #11,#3,$$"62l"
PER.E .HS 00
PHA .DA PHA.E+1-*
.DA #3,$$"PHA"