Work In PrWork in progress on ASM

This commit is contained in:
Rémy GIBERT 2015-10-04 22:55:51 +02:00
parent 3fdea2c2c6
commit f4817adf71
5 changed files with 321 additions and 76 deletions

93
BIN/ASM.S.DIR.txt Normal file
View File

@ -0,0 +1,93 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*---------------------------------------
DIR.AC clc
rts
*---------------------------------------
DIR.AS clc
rts
*---------------------------------------
DIR.AT clc
rts
*---------------------------------------
DIR.AZ clc
rts
*---------------------------------------
DIR.BS clc
rts
*---------------------------------------
DIR.DA clc
rts
*---------------------------------------
DIR.DO clc
rts
*---------------------------------------
DIR.DU clc
rts
*---------------------------------------
DIR.ED clc
rts
*---------------------------------------
DIR.EL clc
rts
*---------------------------------------
DIR.EN clc
rts
*---------------------------------------
DIR.EP clc
rts
*---------------------------------------
DIR.EQ clc
rts
*---------------------------------------
DIR.FI clc
rts
*---------------------------------------
DIR.HS clc
rts
*---------------------------------------
DIR.IN clc
rts
*---------------------------------------
DIR.LI clc
rts
*---------------------------------------
DIR.MA clc
rts
*---------------------------------------
DIR.OP clc
rts
*---------------------------------------
DIR.OR clc
rts
*---------------------------------------
DIR.PG clc
rts
*---------------------------------------
DIR.PH clc
rts
*---------------------------------------
DIR.SE clc
rts
*---------------------------------------
DIR.TA clc
rts
*---------------------------------------
DIR.TF clc
rts
*---------------------------------------
DIR.TI clc
rts
*---------------------------------------
DIR.US clc
rts
*---------------------------------------
MAN
SAVE BIN/ASM.S.DIR
LOAD BIN/ASM.S
ASM

64
BIN/ASM.S.SYM.txt Normal file
View File

@ -0,0 +1,64 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*---------------------------------------
SYM.ClearPrivate
clc
rts
*---------------------------------------
SYM.AddPrivate
clc
rts
*---------------------------------------
SYM.LookupPrivate
clc
rts
*---------------------------------------
SYM.ClearLocal
clc
rts
*---------------------------------------
SYM.AddLocal
clc
rts
*---------------------------------------
SYM.LookupLocal
clc
rts
*---------------------------------------
SYM.AddGlobal
clc
rts
*---------------------------------------
SYM.LookupGlobal
clc
rts
*---------------------------------------
SYM.BLOCK.ALLOC ldx #0
.1 lda SYM.BLOCKS,x
beq .2
inx
cpx #SYM.BLOCK.MAX
bne .1
lda #ERR.SYM.TOO.LONG
sec Out of block error
rts
.2 phx Save next free block
>LDYA SYM.BLOCK.SIZE
>SYSCALL SYS.GetMem
bcs .9
txa
plx
sta SYM.BLOCKS,x
clc
.9 rts
*---------------------------------------
MAN
SAVE BIN/ASM.S.SYM
LOAD BIN/ASM.S
ASM

View File

@ -26,7 +26,7 @@ ERR.SYM.TOO.LONG .EQ 10
ERR.VAL.TOO.BIG .EQ 11
ERR.LINE.TOO.LONG .EQ 20
ERR.INVALID.LABEL .EQ 21
ERR.INVALID.DIRECTIVE .EQ 22
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -52,7 +52,34 @@ L.MSG.HELP2 .DA MSG.HELP2
L.MSG.SRCLINE .DA MSG.SRCLINE
L.MSG.ERROR .DA MSG.ERROR
L.READ.BUFFER .DA READ.BUFFER
T.DIRECTIVES.JMP .DA DIR.LI
L.T.DIRECTIVES .DA T.DIRECTIVES
J.DIRECTIVES .DA DIR.AC
.DA DIR.AS
.DA DIR.AT
.DA DIR.AZ
.DA DIR.BS
.DA DIR.DA
.DA DIR.DO
.DA DIR.DU
.DA DIR.ED
.DA DIR.EL
.DA DIR.EN
.DA DIR.EP
.DA DIR.EQ
.DA DIR.FI
.DA DIR.HS
.DA DIR.IN
.DA DIR.LI
.DA DIR.MA
.DA DIR.OP
.DA DIR.OR
.DA DIR.PG
.DA DIR.PH
.DA DIR.SE
.DA DIR.TA
.DA DIR.TF
.DA DIR.TI
.DA DIR.US
.DA 0
*---------------------------------------
CS.INIT >LDYA L.LIBSTR
@ -93,10 +120,10 @@ CS.INIT.ARGS >SYSCALL SYS.GetMemPtrA
>PUSHA
>SYSCALL SYS.PStrCat
ldy #SRC.hFILENAME
.3 ldy #SRC.hFILENAME
sta (pData),y Store filename
.3 lda (pPs)
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
@ -472,6 +499,15 @@ SRC.ParseLine.SymG jsr SYM.ClearLocal
SRC.ParseLine.OpCde jsr SRC.GetCharNB
beq SRC.ParseLine.Ok
cmp #'.'
beq SRC.ParseLine.Dir
bra SRC.ParseLine.Ok
SRC.ParseLine.Ok lda SRC.Label.Flags
beq .8
@ -484,6 +520,54 @@ SRC.ParseLine.Err1 lda #ERR.INVALID.LABEL
SRC.ParseLine.Err sec
rts
*---------------------------------------
SRC.ParseLine.Dir jsr SRC.GetChar
beq .99
sta SRC.Directive+1
ldy #2
.1 jsr SRC.GetChar
beq .2
sta SRC.Directive,y
iny
cpy #SRC.DIR.MAXLEN+2
bne .1
bra .99
.2 sty SRC.Directive
ldx #0
stz SRC.Directive.ID
.3 lda T.DIRECTIVES,x
beq .99
cmp SRC.Directive
bne .6
phx
ldy #0
.4 inx
iny
lda T.DIRECTIVES,x
cmp SRC.Directive,y
bne .5
cpy SRC.Directive
beq .7
.5 plx
.6 txa
clc
adc T.DIRECTIVES,x
tax
inc SRC.Directive.ID
bra .3
.7
.99 lda #ERR.INVALID.DIRECTIVE
sec
rts
*---------------------------------------
SRC.GetDecimal stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
@ -602,58 +686,6 @@ SRC.GetChar ldx SRC.BufPtr
and #$7f
rts
*---------------------------------------
SYM.ClearPrivate
clc
rts
*---------------------------------------
SYM.AddPrivate
clc
rts
*---------------------------------------
SYM.LookupPrivate
clc
rts
*---------------------------------------
SYM.ClearLocal
clc
rts
*---------------------------------------
SYM.AddLocal
clc
rts
*---------------------------------------
SYM.LookupLocal
clc
rts
*---------------------------------------
SYM.AddGlobal
clc
rts
*---------------------------------------
SYM.LookupGlobal
clc
rts
*---------------------------------------
SYM.BLOCK.ALLOC ldx #0
.1 lda SYM.BLOCKS,x
beq .2
inx
cpx #SYM.BLOCK.MAX
bne .1
lda #ERR.SYM.TOO.LONG
sec Out of block error
rts
.2 phx Save next free block
>LDYA SYM.BLOCK.SIZE
>SYSCALL SYS.GetMem
bcs .9
txa
plx
sta SYM.BLOCKS,x
clc
.9 rts
*---------------------------------------
SRC.ACC10 lda SRC.ACC ACC*2-> ACC & ACCTMP
asl
sta SRC.ACC
@ -696,36 +728,90 @@ SRC.ACC10 lda SRC.ACC ACC*2-> ACC & ACCTMP
.9 rts
*---------------------------------------
DIR.LI clc
rts
.INB BIN/ASM.S.DIR
.INB BIN/ASM.S.SYM
*---------------------------------------
CS.END
T.DIRECTIVES .AS "AS"
SRC.DIR.MAXLEN .EQ 5 (DUMMY)
T.DIRECTIVES .HS 02
.AS "AC"
.HS 02
.AS "AS"
.HS 02
.AS "AT"
.HS 02
.AS "AZ"
.HS 02
.AS "BS"
.HS 02
.AS "DA"
.HS 02
.AS "DO"
.HS 02
.AS "DU"
.HS 05
.AS "DUMMY"
.HS 02
.AS "ED"
.AS "EL"
.HS 04
.AS "ELSE"
.HS 02
.AS "EN"
.HS 02
.AS "EP"
.HS 02
.AS "EQ"
.AS "FI"
.HS 03
.AS "FIN"
.HS 02
.AS "HS"
.HS 02
.AS "IN"
.HS 03
.AS "INB"
.HS 04
.AS "INB1"
.HS 04
.AS "INB2"
.HS 04
.AS "INB3"
.HS 04
.AS "INB4"
.HS 04
.AS "INB5"
.HS 04
.AS "INB6"
.HS 04
.AS "INB7"
.HS 04
.AS "INB8"
.HS 04
.AS "INB9"
.HS 02
.AS "LI"
.HS 04
.AS "LIST"
.HS 02
.AS "MA"
.HS 02
.AS "OP"
.HS 02
.AS "OR"
.HS 02
.AS "PG"
.HS 02
.AS "PH"
.HS 02
.AS "SE"
.HS 02
.AS "TA"
.HS 02
.AS "TF"
.HS 02
.AS "TI"
.HS 02
.AS "US"
T.DIRECTIVES.END .EQ *
.HS 00
*---------------------------------------
LIBSTR >PSTRING "libstr.o"
MSG.HELP1 >CSTRING "A2osX-Macro Assembler (S-C MASM 2.0 Based)\n"
@ -738,6 +824,8 @@ SRC.LINENUM .BS 2
SRC.BufPtr .BS 1
SRC.Label.Flags .BS 1
SRC.Label .BS SRC.LABEL.MAXLEN
SRC.Directive.ID .BS 1
SRC.Directive .BS SRC.DIR.MAXLEN
SRC.LabelValue .BS 4
SRC.ACC .BS 4
SRC.ACCTMP .BS 4

View File

@ -6,7 +6,7 @@ AUTO 6
.TF /A2OSX.BOOT/BIN/ASM.T.6502
.OR $2000
*---------------------------------------
.MA AMS AMSID,"Syntax",0,"Operand",0,"Range",0
.MA AMS AMSID,"Pattern"
.DA #]1
.AS ]2
.DA #0
@ -19,18 +19,18 @@ AUTO 6
.DA T.ADDR.MODES.SYNTAX
.DA T.OPCODES
*---------------------------------------
T.ADDR.MODES.SYNTAX >AMS 1,"","","" Implicit
>AMS 2,"#$1",$1","" Immediate
>AMS 3,"$2","$1=$2-@+1","-127,128" rel
>AMS 4,"$1","$1","" zp
>AMS 5,"$1,X","$1","" zp,x
>AMS 6,"$2","$2","" abs
>AMS 7,"$2,X","$2","" abs,x
>AMS 8,"$2,Y","$2","" abs,y
>AMS 9,"($2)","$2","" (abs)
>AMS 10,"($1)","$1","" (zp)
>AMS 11,"($1,X)","$1","" (zp,x)
>AMS 12,"($1),Y","$1","" (zp),x
T.ADDR.MODES.SYNTAX >AMS 1 Implicit
>AMS 2,"#$1",$1","" Imm8
>AMS 3,"$2","$1=$2-@+1","-127,128" rel8
>AMS 4,"$1","$1","" abs8
>AMS 5,"$1,X","$1","" abs8,x
>AMS 6,"$2","$2","" abs16
>AMS 7,"$2,X","$2","" abs16,x
>AMS 8,"$2,Y","$2","" abs16,y
>AMS 9,"($2)","$2","" (abs16)
>AMS 10,"($1)","$1","" (abs8)
>AMS 11,"($1,X)","$1","" (abs8,x)
>AMS 12,"($1),Y","$1","" (abs8),y
.HS 0
*---------------------------------------
T.OPCODES .AS "ADC"

View File

@ -27,7 +27,7 @@ T.ADDR.MODES.SYNTAX >AMS 1,"","","" Implicit
>AMS 9,"($2)","$2","" (abs)
>AMS 10,"($1)","$1","" (zp)
>AMS 11,"($1,X)","$1","" (zp,x)
>AMS 12,"($1),Y","$1","" (zp),x
>AMS 12,"($1),Y","$1","" (zp),y
T.OPCODES .AS "ADC"
.HS 0