Work In Progress (ASM)

This commit is contained in:
Rémy GIBERT 2015-11-20 17:31:14 +01:00
parent 7fa3545a19
commit 71a00af938
6 changed files with 518 additions and 148 deletions

View File

@ -47,6 +47,12 @@ DIR.EP clc
*---------------------------------------
DIR.EQ jsr EXP.Eval
bcs .9
ldx #3
.1 lda SRC.ACC,x
sta SRC.GLabel.Value,x
dex
bpl .1
clc
.9 rts
@ -63,13 +69,23 @@ DIR.IN jsr SRC.GetArg
>LDYA L.SRC.BUFFER
>SYSCALL SYS.NewPStrYA
pha
jsr FIO.OpenFileA
bcs .99
plx
php
pha
txa
>SYSCALL SYS.FreeMemA
pla
plp
rts
.9 lda #ERR.SYNTAX.ERROR
.99 sec
sec
rts
*---------------------------------------
DIR.LI >LDYA L.T.LI
@ -100,6 +116,10 @@ DIR.LI.ON ldy #ASM.LI.ON
DIR.LI.OFF ldy #ASM.LI.ON
clc
DIR.LI.APPLY lsr
lda #$80
sta (pData),y
rts
*---------------------------------------

View File

@ -13,22 +13,26 @@ AUTO 6
* & = octal
* * = PC
*---------------------------------------
EXP.Eval jsr SRC.GetCharNB
EXP.Eval stz EXP.Operator
jsr SRC.GetCharNB
beq .98
cmp #'*'
bne .10
ldy #ASM.PC
ldx #0
ldy #ASM.PC+3
ldx #3
.11 lda (pData),y
sta SRC.ACC,x
inx
iny
cpx #4
bne .11
dey
dex
bpl .11
bra .8
jsr SRC.GetCharNB
bne .97
clc
rts
.10 jsr SRC.IsDigit10 Decimal constant ?
bcs .1
@ -62,7 +66,24 @@ EXP.Eval jsr SRC.GetCharNB
.4 jsr SRC.IsLetter Symbol ?
bcs .97
dec SRC.BufPtr
>LDYA L.SRC.ELabel.Len
jsr SRC.GetLabel
bcs .97
jsr SYM.FindGlobal
bcc .41
ldy #ASM.PASS
lda (pData),y pass#2?
bne .96 yes, undefined symbol
jsr
.41 ldx #3
.5 lda SRC.FLabel.Value,x
sta SRC.ACC,x
dex
bpl .5
.8 clc
rts
@ -74,6 +95,10 @@ EXP.Eval jsr SRC.GetCharNB
.98 lda #ERR.MISSING.EXP
sec
.99 rts
.96 lda #ERR.UNDEF.SYMBOL
sec
rts
*---------------------------------------
stz SRC.ACC
stz SRC.ACC+1

View File

@ -5,21 +5,25 @@ INC 1
AUTO 6
.LIST OFF
*---------------------------------------
FIO.OpenFileA sta hFileName
FIO.OpenFileA sta FIO.hFileName
>SYSCALL SYS.GetMemPtrA
>STYA ZPPtr1
stz FIO.hFullPath
ldy #1
lda (ZPPtr1),y
cmp #'/'
beq .1
>PUSHB hFileName
>PUSHB FIO.hFileName
ldy #S.PS.hPREFIX
lda (pPs),y
>PUSHA
>SYSCALL SYS.PStrCat
sta hFileName
sta FIO.hFullPath
sta FIO.hFileName
>SYSCALL SYS.GetMemPtrA
>STYA ZPPtr1
@ -34,9 +38,9 @@ FIO.OpenFileA sta hFileName
lda #ERR.SRC.TOO.MANY.IN
sec
rts
bra FIO.OpenFileA.Exit
.10 lda hFileName
.10 lda FIO.hFileName
>SYSCALL SYS.MLIOpenA
bcs .99
@ -57,7 +61,7 @@ FIO.OpenFileA sta hFileName
txa
sta (pData),y
lda hFileName
lda FIO.hFileName
>SYSCALL SYS.MLIGetFileInfoA
bcs .99
@ -100,11 +104,18 @@ FIO.OpenFileA sta hFileName
inc
sta (pData),y
clc
rts
bra FIO.OpenFileA.Exit
.98 lda #ERR.SRC.INV.TYPE
.99 sec
FIO.OpenFileA.Exit php
pha
lda FIO.hFullPath
beq .1
>SYSCALL SYS.FreeMemA
.1 pla
plp
rts
*---------------------------------------
FIO.ReadLine stz SRC.BufPtr

View File

@ -13,10 +13,12 @@ SRC.ParseLine ldx TmpBuffer256
cpx #';' Comment?
beq SRC.ParseLine.Skip
stz SRC.GLabel.New
cpx #' ' no label...go scan dir/opcode
beq .4
.1 cpx #'.' local symbol?
cpx #'.' local symbol?
bne .2
jsr SRC.ParseLine.SymL
bra .3
@ -46,47 +48,117 @@ SRC.ParseLine ldx TmpBuffer256
bcs SRC.ParseLine.Err
SRC.ParseLine.Ok lda SRC.GLabel.Len
beq .1
SRC.ParseLine.Ok lda SRC.GLabel.New
bpl .1
* jsr SYM.AddToGBlock
* bcs SRC.ParseLine.Err
.1
lda SRC.GLabel.Flags
lsr .SE ?
bcs .1 yes, update during pass 1 & 2
ldy #ASM.PASS
lda (pData),y pass#2?
bne .8 yes, skip to avoid redefinition error
jsr SYM.FindGlobal
bcs SRC.ParseLine.Redef
.1 jsr SYM.AddGToGBlock
bcs SRC.ParseLine.Err
.8
SRC.ParseLine.skip clc
rts
SRC.ParseLine.Err1 lda #ERR.INVALID.LABEL
SRC.ParseLine.Err sec
rts
SRC.ParseLine.Redef lda #ERR.SYMBOL.REDEFINE
sec
rts
*---------------------------------------
SRC.ParseLine.SymP jsr SRC.GetChar
beq SRC.ParseLine.SymE
jsr SRC.GetDecimal
bcs SRC.ParseLine.SymR
bcs SRC.ParseLine.SymE
jmp SYM.AddPrivate
*---------------------------------------
SRC.ParseLine.SymL jsr SRC.GetChar
beq SRC.ParseLine.SymE
jsr SRC.GetDecimal
bcs SRC.ParseLine.SymR
jmp SYM.AddLocal
bcs SRC.ParseLine.SymE
lda SRC.ACC+1
ora SRC.ACC+2
ora SRC.ACC+3
bne SRC.ParseLine.SymE Max .255
lda SRC.ACC
beq SRC.ParseLine.SymE .0 is not allowed
sta SRC.LLabel.ID
ldy #ASM.PC
lda (pData),y
ldy #ASM.PC.GLABEL
sec
sbc (pData),y
sta SRC.LLabel.Offset
ldy #ASM.PC+1
lda (pData),y
ldy #ASM.PC.GLABEL+1
sbc (pData),y
bne SRC.ParseLine.SymR
ldy #ASM.PC+2
lda (pData),y
ldy #ASM.PC.GLABEL+2
sbc (pData),y
bne SRC.ParseLine.SymR
ldy #ASM.PC+3
lda (pData),y
ldy #ASM.PC.GLABEL+3
sbc (pData),y
bne SRC.ParseLine.SymR
bcc SRC.ParseLine.SymR
jmp SYM.AddLToGBlock
*---------------------------------------
SRC.ParseLine.SymG jsr SRC.GetGLabel
SRC.ParseLine.SymE lda #ERR.INVALID.LABEL
sec
rts
SRC.ParseLine.SymR lda #ERR.RANGE
sec
rts
*---------------------------------------
SRC.ParseLine.SymG >LDYA L.SRC.GLabel.Len
jsr SRC.GetLabel
bcs SRC.ParseLine.SymE
ldx #3 Makes Current Label = PC for now
ldy #ASM.PC
lda (pdata),y
.1 sta SRC.GLabel.Value,x
ldy #ASM.PC+3
.1 lda (pData),y
sta SRC.GLabel.Value,x
dey
dex
bpl .1
ldx #3 Makes Current Label = Ref for next local
ldy #ASM.PC.GLABEL+3
.2 lda SRC.GLabel.Value,x
sta (pData),y
dey
dex
bpl .2
lda #$80 Mark GLabel Flag...
sta SRC.GLabel.Flags
sta SRC.GLabel.New
clc
rts
SRC.ParseLine.SymE lda #ERR.INVALID.LABEL
sec
SRC.ParseLine.SymR rts
*---------------------------------------
SRC.ParseLine.Dir >LDYA L.T.DIRECTIVES
jsr SRC.GetKeyword
@ -154,7 +226,18 @@ SRC.ParseLine.OpCode
jsr SRC.ParseLine.AM
bcs .99
clc
ldy #ASM.PC
lda (pData),y
inc
sta (pData),y
bne .2
iny
lda (pData),y
inc
sta (pData),y
.2 clc
rts
.7 lda ZPPtr1
@ -189,14 +272,7 @@ SRC.ParseLine.AM stz SRC.AM.ID
sta SRC.AM.StrBuf,x
bra .1
.8 lda SRC.AM.StrBuf
beq .89
>PUSHWI TmpBuffer256
>PUSHW L.SRC.AM.StrBuf
>PUSHB SRC.AM.StrBuf
>PUSHW L.MSG.DEBUG
>LIBCALL hLIBSTR,LIBSTR.PRINTF
.89 clc
.8 clc
rts
.2 jsr SRC.IsLetter Any register?
@ -207,7 +283,7 @@ SRC.ParseLine.AM stz SRC.AM.ID
inc SRC.AM.tmpBuf
.3 jsr SRC.GetCharUC
beq .4
beq .41
jsr SRC.IsLetterOrDigit
bne .4
inc SRC.AM.tmpBuf
@ -217,7 +293,7 @@ SRC.ParseLine.AM stz SRC.AM.ID
.4 dec SRC.BufPtr back one char
ldy #0
.41 ldy #0
.5 lda (ZPPtr3),y
beq .71 last register ?
@ -241,10 +317,11 @@ SRC.ParseLine.AM stz SRC.AM.ID
.61 iny
lda SRC.AM.tmpBuf,y
sta SRC.AM.StrBuf,x
inx
sta SRC.AM.StrBuf,x
cpy SRC.AM.tmpBuf
bne .61
stx SRC.AM.StrBuf
bra .72
@ -258,7 +335,7 @@ SRC.ParseLine.AM stz SRC.AM.ID
.70 dec SRC.BufPtr back one char
.71 jsr SRC.GetExp
.71 jsr EXP.Eval
bcs .99
.72 jmp .1
clc
@ -313,7 +390,7 @@ SRC.GetDecimal stz SRC.ACC+1
jsr SRC.ACC10
pla
bcs .9
clc
adc SRC.ACC
sta SRC.ACC
bcc .1
@ -344,7 +421,7 @@ SRC.GetHex stz SRC.ACC+1
beq .99
jsr SRC.IsDigit16
bcs .99
and #$0F
sta SRC.ACC
.1 jsr SRC.GetChar
@ -354,20 +431,16 @@ SRC.GetHex stz SRC.ACC+1
jsr SRC.IsDigit16
bcs .99
asl
asl
asl
asl
ldx #4
.2 asl
rol SRC.ACC
.2 asl SRC.ACC
rol SRC.ACC+1
rol SRC.ACC+2
rol SRC.ACC+3
bcs .9
dex
bne .2
ora SRC.ACC
sta SRC.ACC
bra .1
.8 clc
@ -467,37 +540,44 @@ SRC.GetBinary stz SRC.ACC+1
sec
rts
*---------------------------------------
SRC.GetGLabel jsr SRC.GetCharUC
SRC.GetLabel >STYA ZPPtr1
jsr SRC.GetCharUC
beq .9
jsr SRC.IsLetter
bcs .9
sta SRC.GLabel.Name
ldy #1
sta (ZPPtr1),y
.1 jsr SRC.GetCharUC
beq .8
cmp #' '
beq .8
cmp #'.'
beq .2
cmp #'_'
beq .2
jsr SRC.IsEXPReserved
bcc .8
jsr SRC.IsLetterOrDigit
bcs .9
.2 sta SRC.GLabel.Name,y
iny
.2 iny
sta (ZPPtr1),y
cpy #SRC.GLABEL.MAXLEN
bne .1 if equ Carry is set
bcc .1 if equ Carry is set
.9 sec
.9 lda #ERR.SYNTAX.ERROR
sec
rts
.8 tya
sta SRC.GLabel.Len
sta (ZPPtr1)
clc
rts
*---------------------------------------
@ -544,7 +624,7 @@ SRC.GetKeyword >STYA ZPPtr1
.9 sec
rts
*---------------------------------------
SRC.GetExp stz SRC.Exp
SRC.GetExp.DELETE stz SRC.Exp
jsr SRC.GetCharUC
beq .9
@ -634,11 +714,11 @@ SRC.IsDigit16 jsr SRC.IsDigit10
bcc .8
cmp #'A'
bcc .9
cmp #'G'
cmp #'F'+1
bcc .1
rts cc if ok, cs if not
.1 sbc #'A'-10 cc so A->10
.1 sbc #'A'-11 cc so A->10 (11-CC)
clc
.8 and #$0F
rts
@ -702,8 +782,8 @@ SRC.ACC10 lda SRC.ACC ACC*2-> ACC & ACCTMP
sta SRC.ACCTMP+3
bcs .9
ldx #1
.1 asl SRC.ACC ACC=ACC*8
ldx #2
.1 asl SRC.ACC ACC=ACC*4
rol SRC.ACC+1
rol SRC.ACC+2
rol SRC.ACC+3

View File

@ -6,15 +6,16 @@ AUTO 6
.LIST OFF
*---------------------------------------
* Global Symbol Record: (8+ bytes)
* 0-3 : 32 bits Value
* 4 : Flags:
* b7=R/W (.SE)
* 0 : Flags:
* b7=Valid Entry
* b6=pending
* b0=R/W (.SE)
* 1-4 : 32 bits Value
* 5 : Len
* 6-... Name
* ......
* Local Symbol Record: (2 bytes)
* 2 : Local ID (0->255)
* 2 : Local ID (1->255)
* 3 : offset from Global Symbol
* ......
* Ending 0
@ -30,7 +31,14 @@ AUTO 6
*---------------------------------------
* Macro Record: ( bytes)
*---------------------------------------
SYM.Init jsr SYM.NewGBlock
SYM.Init lda #0
ldy #SYM.iCurGBlock
sta (pData),y
dec
ldy #SYM.hCurGBlock
sta (pData),y
jsr SYM.NewGBlock
bcs .9
clc
@ -39,7 +47,7 @@ SYM.Init jsr SYM.NewGBlock
SYM.Quit ldy #SYM.LastGBlock
lda (pData),y
bmi .8
.1 clc
adc #SYM.hGBlocks
tay
@ -54,21 +62,78 @@ SYM.Quit ldy #SYM.LastGBlock
.8 clc
rts
*---------------------------------------
SYM.AddGlobal
clc
rts
*---------------------------------------
SYM.LookupGlobal
clc
rts
*---------------------------------------
SYM.AddLocal
clc
rts
*---------------------------------------
SYM.LookupLocal
SYM.Dump >PUSHW L.MSG.SYMBOLS
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #SYM.DumpCount
lda #20
sta (pData),y
jsr SYM.ResetGBlock
.1 jsr SYM.GetByteGBlock Get Flags
sta SRC.GLabel.Flags
bne .10
clc
rts
.10 ldx #0
.2 jsr SYM.GetByteGBlock
sta SRC.GLabel.Value,x
inx
cpx #4
bne .2
jsr SYM.GetByteGBlock
sta SRC.GLabel.Len
ldx #0
.3 jsr SYM.GetByteGBlock
sta SRC.GLabel.Name,x
inx
cpx SRC.GLabel.Len
bne .3
>PUSHW L.SRC.GLabel.Len
lda SRC.GLabel.Value+1
>PUSHA
lda SRC.GLabel.Value
>PUSHA
lda SRC.GLabel.Value+3
>PUSHA
lda SRC.GLabel.Value+2
>PUSHA
>PUSHW L.MSG.GSYMBOL
>LIBCALL hLIBSTR,LIBSTR.PRINTF
* bcs .9
.4 jsr SYM.GetByteGBlock
beq .5 End Locals...proceed next Global
pha
jsr SYM.GetByteGBlock
>PUSHA
pla
>PUSHA
>PUSHW L.MSG.LSYMBOL
>LIBCALL hLIBSTR,LIBSTR.PRINTF
* bcc .4
bra .4
.5 lda #13
jsr COUT
ldy #SYM.DumpCount
lda (pData),y
dec
bne .6
>DEBUG
lda #20
.6 sta (pData),y
jmp .1
.9 rts
*---------------------------------------
SYM.AddPrivate
clc
@ -86,75 +151,183 @@ SYM.LookupMacro
clc
rts
*---------------------------------------
SYM.AddToGBlock ldy #SYM.GBlockPtr
lda (pData),y
clc
adc #6 Value+Flags+Len
bcs .1
adc SRC.GLabel.Len
bcs .1
SYM.UpdateGlobal
*---------------------------------------
SYM.FindGlobal jsr SYM.ResetGBlock
ldy #SYM.LastGBlock
lda (pData),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPPtr1
bra .2
.1 jsr SYM.NewGBlock
bcs .9
>STYA ZPPtr1
.2 ldx #0
ldy #SYM.GBlockPtr
.3 lda SRC.GLabel.Value,x
sta (ZPPtr1),y
inx
iny
cpx #6
bne .3
.1 jsr SYM.GetByteGBlock Get Flags
beq .9
sta SRC.FLabel.Flags
ldx #0
.4 lda SRC.GLabel.Name,x
sta (ZPPtr1),y
.2 jsr SYM.GetByteGBlock
sta SRC.FLabel.Value,x
inx
iny
cpx SRC.GLabel.Len
bne .4
cpx #4
bne .2
jsr SYM.GetByteGBlock
sta SRC.FLabel.Len
ldx #0
.3 jsr SYM.GetByteGBlock
sta SRC.FLabel.Name,x
inx
cpx SRC.FLabel.Len
bne .3
tya
ldy #SYM.GBlockPtr
sta (pData),y set new SYM.GBlockPtr
cpx SRC.ELabel.Len
bne .5
.4 lda SRC.FLabel.Name-1,x
cmp SRC.ELabel.Name-1,x
bne .5
dex
bne .4
clc
.9
rts
.5 jsr SYM.GetByteGBlock
beq .1
jsr SYM.GetByteGBlock
bra .5
.9 sec
rts
*---------------------------------------
SYM.NewGBlock >PUSHWI 256
SYM.AddLToGBlock jsr SYM.GetLastGBlock
lda SRC.LLabel.ID
jsr SYM.AddByteGBlock
bcs .9
lda SRC.LLabel.Offset
jmp SYM.AddByteGBlock
.9 rts
*---------------------------------------
SYM.AddGToGBlock jsr SYM.GetLastGBlock
ldy #SYM.hCurGBlock 1st Gblock to add?
lda (pData),y
ldy #SYM.iCurGBlock
ora (pData),y
beq .10 yes, skip closing previous one
lda #0 Close Pending Global/Local
jsr SYM.AddByteGBlock
bcs .9
.10 ldx #0
.1 lda SRC.GLabel.Flags,x
jsr SYM.AddByteGBlock
bcs .9
inx
cpx #6
bne .1
ldx #0
.2 lda SRC.GLabel.Name,x
jsr SYM.AddByteGBlock
bcs .9
inx
cpx SRC.GLabel.Len
bne .2
clc
.9 rts
*---------------------------------------
SYM.ResetGBlock ldy #SYM.hGBlocks
lda (pData),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPBlockPtr
lda #0
ldy #SYM.hCurGBlock
sta (pData),y
ldy #SYM.iCurGBlock
sta (pData),y
rts
*---------------------------------------
SYM.GetByteGBlock ldy #SYM.iCurGBlock
lda (pData),y
tay
lda (ZPBlockPtr),y
pha
ldy #SYM.iCurGBlock
lda (pData),y
inc
sta (pData),y
bne .1
ldy #SYM.hCurGBlock
lda (pData),y
inc
sta (pData),y
jsr SYM.GetGBlockA
.1 pla
clc
rts
*---------------------------------------
SYM.GetLastGBlock ldy #SYM.LastGBlock
lda (pData),y
SYM.GetGBlockA clc
adc #SYM.hGBlocks
tay
lda (pData),y
phx
>SYSCALL SYS.GetMemPtrA
>STYA ZPBlockPtr
plx
rts
*---------------------------------------
SYM.AddByteGBlock pha
ldy #SYM.iCurGBlock
lda (pData),y
tay
pla
sta (ZPBlockPtr),y
tya
inc
beq SYM.NewGBlock
ldy #SYM.iCurGBlock
sta (pData),y
clc
rts
*---------------------------------------
SYM.NewGBlock phx
>PUSHWI 256
>PUSHBI S.MEM.F.INIT0
>SYSCALL SYS.GetMem
bcs .9
>STYA ZPPtr1
>STYA ZPBlockPtr
ldy #SYM.LastGBlock
lda (pData),y
inc
sta (pData),y
ldy #SYM.hGBlocks
clc
adc (pData),y
adc #SYM.hGBlocks
tay
txa
sta (pData),y
lda #0
ldy #SYM.GBlockPtr
ldy #SYM.iCurGBlock
sta (pData),y
clc
.9 rts
*---------------------------------------
.9 plx
rts
*---------------------------------------
MAN
SAVE BIN/ASM.S.SYM
LOAD BIN/ASM.S

View File

@ -16,6 +16,7 @@ AUTO 6
ZPPtr1 .EQ ZPBIN
ZPPtr2 .EQ ZPBIN+2
ZPPtr3 .EQ ZPBIN+4
ZPBlockPtr .EQ ZPBIN+6
*---------------------------------------
ASM.T.AM .EQ 0
ASM.T.R .EQ 2
@ -24,7 +25,7 @@ ASM.T.O .EQ 4
SRC.IN.MAXDEPTH .EQ 7
SRC.GLABEL.MAXLEN .EQ 32
*---------------------------------------
SYM.GBLOCK.MAX .EQ 64 64*256=16k
SYM.GBLOCK.MAX .EQ 96 96*256=24k
SYM.SBLOCK.MAX .EQ 16 16*256=4k
SYM.PBLOCK.MAX .EQ 32 32*256=8k
SYM.MBLOCK.MAX .EQ 32 32*256=8k
@ -43,6 +44,9 @@ ERR.INVALID.DIRECTIVE .EQ $A5
ERR.INVALID.OPCODE .EQ $A6
ERR.INVALID.AM.SYN .EQ $A7
ERR.INVALID.AM.4.OC .EQ $A8
ERR.RANGE .EQ $A9
ERR.UNDEF.SYMBOL .EQ $AA
ERR.SYMBOL.REDEFINE .EQ $AB
ERR.MISSING.EXP .EQ $B0
ERR.EXP.SYN.ERROR .EQ $B1
ERR.INVALID.MACRO.DEF .EQ $E0
@ -71,11 +75,17 @@ L.MSG.HELP2 .DA MSG.HELP2
L.MSG.SRCLINE .DA MSG.SRCLINE
L.MSG.ERROR .DA MSG.ERROR
L.MSG.DEBUG .DA MSG.DEBUG
L.SRC.AM.StrBuf .DA SRC.AM.StrBuf
L.MSG.SYMBOLS .DA MSG.SYMBOLS
L.MSG.GSYMBOL .DA MSG.GSYMBOL
L.MSG.LSYMBOL .DA MSG.LSYMBOL
L.MSG.SUMMARY .DA MSG.SUMMARY
L.MSG.PASS .DA MSG.PASS
L.MSG.SRC.FILE .DA MSG.SRC.FILE
L.MSG.OBJ.FILE .DA MSG.OBJ.FILE
L.MSG.T.FILE .DA MSG.T.FILE
L.SRC.AM.StrBuf .DA SRC.AM.StrBuf
L.SRC.GLabel.Len .DA SRC.GLabel.Len
L.SRC.ELabel.Len .DA SRC.ELabel.Len
L.SRC.BUFFER .DA SRC.BUFFER
L.ASM.T.FILENAME .DA ASM.T.FILENAME
L.T.DIRECTIVES .DA T.DIRECTIVES
@ -177,6 +187,9 @@ CS.INIT >LDYA L.LIBSTR
jsr LOAD.ASM.T
bcs .99
jsr SYM.Init
bcs .99
lda #$80
ldy #ASM.LI.ON
sta (pData),y
@ -243,7 +256,12 @@ CS.RUN ldy #bCANCEL
clc
rts
.1 lda #0 End of assembly, exit with no error
.1 jsr SYM.Dump
>PUSHW L.MSG.SUMMARY
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda #0 End of assembly, exit with no error
.99 sec
rts
@ -306,6 +324,8 @@ CS.DOEVENT ldy #S.EVT.hDEV is Event from active IN device?
CS.QUIT jsr FIO.FileClose
bne CS.QUIT
jsr SYM.Quit
ldy #ASM.T.hMem
lda (pData),y
beq .1
@ -322,6 +342,15 @@ CS.QUIT jsr FIO.FileClose
clc
rts
*---------------------------------------
COUT phx
phy
ldx #DEVMGR.COUT
jsr pDevJmp
ply
plx
rts
pDevJmp jmp (pDev)
*---------------------------------------
.INB BIN/ASM.S.DIR
.INB BIN/ASM.S.EXP
.INB BIN/ASM.S.FIO
@ -430,19 +459,29 @@ LIBSTR >PSTRING "libstr.o"
MSG.HELP1 >CSTRING "A2osX-Macro Assembler (S-C MASM 3.0 Based)\n"
MSG.HELP2 >CSTRING "Usage : ASM <src file> [type TXT ($04) or S-C/BAS ($FA)]\n"
MSG.PASS >CSTRING "Pass:#%d\n"
MSG.SRC.FILE >CSTRING "Source File:%S\n"
MSG.OBJ.FILE >CSTRING "Object File:%S, Type=%02x\n"
MSG.T.FILE >CSTRING "CPU Definition File:%S\n"
MSG.SRC.FILE >CSTRING "Reading SRC File:%S\n"
MSG.OBJ.FILE >CSTRING "Writing OBJ File:%S, Type=%02x\n"
MSG.T.FILE >CSTRING "Loading CPU File:%S\n"
MSG.SRCLINE >CSTRING "%05D-%s\n"
MSG.ERROR >CSTRING "%05D-Error:$%h\n"
MSG.DEBUG >CSTRING "DEBUG:%h:%S:%s\n"
MSG.SYMBOLS >CSTRING "Symbol Table:\n"
MSG.GSYMBOL >CSTRING "$%H%H:%S"
MSG.LSYMBOL >CSTRING " .%d:+$%h"
MSG.SUMMARY >CSTRING "\nEnd Of Assembly.\n"
SRC.AM.RESERVED >PSTRING "[]#(),"
SRC.MOD.RESERVED >PSTRING "#/<>"
SRC.EXP.RESERVED >PSTRING "^!|&<=>+-*/"
ASM.T.DEFAULT .AS ".T.6502"
ASM.T.FILENAMELEN .BS 1
ASM.T.FILENAME .BS 65
hLIBSTR .BS 1
hFileName .BS 1
FIO.hFileName .BS 1
FIO.hFullPath .BS 1
EXP.Operator .BS 1
SRC.LINENUM .BS 2
SRC.Directive.ID .BS 1
SRC.Keyword.ID .BS 1
@ -456,10 +495,21 @@ SRC.BufPtr .BS 1
SRC.BufPtrSave .BS 1
SRC.Buffer .BS 256
*--------------------------------------
SRC.GLabel.Value .BS 4
SRC.GLabel.New .BS 1
SRC.GLabel.Flags .BS 1
SRC.GLabel.Value .BS 4
SRC.GLabel.Len .BS 1
SRC.GLabel.Name .BS SRC.GLABEL.MAXLEN
SRC.LLabel.ID .BS 1
SRC.LLabel.Offset .BS 1
SRC.ELabel.Flags .BS 1
SRC.ELabel.Value .BS 4
SRC.ELabel.Len .BS 1
SRC.ELabel.Name .BS SRC.GLABEL.MAXLEN
SRC.FLabel.Flags .BS 1
SRC.FLabel.Value .BS 4
SRC.FLabel.Len .BS 1
SRC.FLabel.Name .BS SRC.GLABEL.MAXLEN
*--------------------------------------
.DUMMY
.OR 0
@ -481,21 +531,27 @@ DST.hFILETYPE .BS 1
ASM.T.hMem .BS 1 handle to ASM.T.xxxxx
SYM.LastGBlock .BS 1
SYM.hGBlocks .BS SYM.GBLOCK.MAX
SYM.GBlockPtr .BS 1
SYM.hCurSBlock .BS 1
SYM.iCurSBlock .BS 1
SYM.LastSBlock .BS 1
SYM.hSBlocks .BS SYM.SBLOCK.MAX
SYM.SBlockPtr .BS 1
SYM.LastPBlock .BS 1
SYM.hCurGBlock .BS 1
SYM.iCurGBlock .BS 1
SYM.LastGBlock .BS 1
SYM.hGBlocks .BS SYM.GBLOCK.MAX
SYM.hCurPBlock .BS 1
SYM.iCurPBlock .BS 1
SYM.LastPBlock .BS 1
SYM.hPBlocks .BS SYM.PBLOCK.MAX
SYM.PrivateBlockPtr .BS 1
SYM.LastMBlock .BS 1
SYM.hCurMBlock .BS 1
SYM.iCurMBlock .BS 1
SYM.LastMBlock .BS 1
SYM.hMBlocks .BS SYM.MBLOCK.MAX
SYM.MBlockPtr .BS 1
SYM.DumpCount .BS 1
ASM.PASS .BS 1
ASM.MACRO.ON .BS 1
@ -505,10 +561,15 @@ ASM.LI.CON .BS 1
ASM.LI.XON .BS 1
ASM.PC .BS 4 32Bits PC
ASM.PC.PH .BS 4 32Bits PC saved for PH directive
ASM.PC.GLABEL .BS 4 32Bits PC for last Label (for local labels)
ASM.LOCAL.OFFSET .BS 1 Store local offset from last Global Symbol for local (.xx)
ASM.LOCAL.INVALID .BS 1 If not in global or offset out of range this flag is set
ASM.SYM.ID .BS 2 For reference when a local label is parsed
DS.END .ED
*---------------------------------------
.DO DS.END-DS.START>$FF
ERROR:DS too big
.FIN
*---------------------------------------
MAN
SAVE BIN/ASM.S