Work In Progress

This commit is contained in:
Rémy GIBERT 2015-09-25 17:50:15 +02:00
parent 602468b956
commit 066614dab8

View File

@ -19,9 +19,11 @@ SRC.IN.DEPTH.MAX .EQ 7
*--------------------------------------- *---------------------------------------
ERR.INV.ARGS .EQ 1 ERR.INV.ARGS .EQ 1
ERR.SRC.INV.TYPE .EQ 2 ERR.SRC.INV.TYPE .EQ 2
ERR.SRC.TOO.LONG .EQ 3 ERR.SRC.TOO.MANY.IN .EQ 3
ERR.SRC.TOO.MANY.IN .EQ 4
ERR.SYM.TOO.LARGE .EQ 10 ERR.SYM.TOO.LARGE .EQ 10
ERR.LINE.TOO.LONG .EQ 20
ERR.INVALID.LABEL .EQ 21
*-------------------------------------- *--------------------------------------
* File Header (16 Bytes) * File Header (16 Bytes)
*-------------------------------------- *--------------------------------------
@ -116,6 +118,9 @@ CS.RUN ldy #bCANCEL
.2 jsr SRC.ReadLine .2 jsr SRC.ReadLine
bcs .9 bcs .9
jsr SRC.ParseLine
bcs .9
>PUSHWI TmpBuffer256 >PUSHWI TmpBuffer256
>PUSHW SRC.LINENUM >PUSHW SRC.LINENUM
>PUSHW L.MSG.SRCLINE >PUSHW L.MSG.SRCLINE
@ -251,7 +256,7 @@ SRC.OPEN sta hFileName
bcs .99 bcs .99
bra .8 bra .8
.1 cmp #$FA BAS? .1 cmp #$FA S-C/BAS?
bne .98 bne .98
.8 ldy #SRC.COUNT .8 ldy #SRC.COUNT
@ -272,10 +277,10 @@ SRC.ReadLine ldy #SRC.COUNT
adc #SRC.hFILETYPES-1 adc #SRC.hFILETYPES-1
tay tay
lda (pData),y lda (pData),y
bmi SRC.ReadLine.BIN bmi SRC.ReadLine.TFA
jmp SRC.ReadLine.TXT jmp SRC.ReadLine.T04
*--------------------------------------- *---------------------------------------
SRC.ReadLine.BIN >LDYAI 3 LEN + LINENUM SRC.ReadLine.TFA >LDYAI 3 LEN + LINENUM
jsr SRC.ReadLine.YA jsr SRC.ReadLine.YA
bcs .9 bcs .9
@ -284,13 +289,13 @@ SRC.ReadLine.BIN >LDYAI 3 LEN + LINENUM
lda READ.BUFFER+2 lda READ.BUFFER+2
sta SRC.LINENUM+1 sta SRC.LINENUM+1
lda READ.BUFFER lda READ.BUFFER LEN
dec sec
dec sbc #3 remove LEN + LINENUM from LEN
dec bcc .9 LEN should be at least 3
beq .8 beq .8
tay tay Read remaining chars
lda #0 lda #0
jsr SRC.ReadLine.YA jsr SRC.ReadLine.YA
bcs .9 bcs .9
@ -307,6 +312,7 @@ SRC.ReadLine.BIN >LDYAI 3 LEN + LINENUM
iny iny
bne .1 bne .1
bra .99 bra .99
.2 cmp #$C0 REPEAT char? .2 cmp #$C0 REPEAT char?
bne .5 bne .5
iny iny
@ -342,11 +348,11 @@ SRC.ReadLine.BIN >LDYAI 3 LEN + LINENUM
.8 clc .8 clc
.9 rts .9 rts
.99 lda #ERR.SRC.TOO.LONG .99 lda #ERR.LINE.TOO.LONG
sec sec
rts rts
*-------------------------------------- *--------------------------------------
SRC.ReadLine.TXT SRC.ReadLine.T04
clc clc
rts rts
*-------------------------------------- *--------------------------------------
@ -362,12 +368,66 @@ SRC.ReadLine.YA >PUSHYA
>SYSCALL SYS.MLIRead >SYSCALL SYS.MLIRead
rts rts
*--------------------------------------- *---------------------------------------
SYM.ADD SRC.ParseLine stz SRC.BufPtr
jsr SRC.GetNextChar
beq .8
cmp #'*' Comment?
beq .8
cmp #' '
beq SRC.ParseLine.OpCode
SRC.ParseLine.Sym cmp #'.' Local Label?
bne SRC.ParseLine.SymG
jsr SRC.GetNextToken
bcs
jsr SRC.IsNumber
bcs SRC.ParseLine.Err1
SRC.ParseLine.SymG
jsr SRC.GetToken
jsr SYM.ClearLocal
SRC.ParseLine.OpCode
jsr SRC.GetNextCharNB
beq .8
.8 clc
rts
SRC.ParseLine.Err1 lda #ERR.INVALID.LABEL
sec
rts
*---------------------------------------
SRC.GetToken
*---------------------------------------
SRC.GetNextCharNB jsr SRC.GetNextChar
beq .9
cmp #' '
beq SRC.GetNextCharNB
.9 rts
*---------------------------------------
SRC.GetNextChar ldx SRC.BufPtr
lda TmpBuffer256,x
inc SRC.BufPtr
and #$7f
rts
*---------------------------------------
SYM.ClearLocal
clc clc
rts rts
*--------------------------------------- *---------------------------------------
SYM.LOOKUP SYM.AddLocal
clc
rts
*---------------------------------------
*---------------------------------------
SYM.AddGlobal
clc
rts
*---------------------------------------
SYM.Lookup
clc clc
rts rts
*--------------------------------------- *---------------------------------------
@ -426,6 +486,8 @@ MSG.SRCLINE >CSTRING "%05D-%s\n"
hLIBSTR .BS 1 hLIBSTR .BS 1
hFileName .BS 1 hFileName .BS 1
SRC.LINENUM .BS 2 SRC.LINENUM .BS 2
SRC.BufPtr .BS 1
SRC.Token .BS 256
READ.BUFFER .BS 256 READ.BUFFER .BS 256
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY