Kernel 0.9.1 : ASM rewrite...more directives & better output

This commit is contained in:
Rémy GIBERT 2018-02-02 15:55:20 +00:00
parent e1cd14fbce
commit e95b70c710
6 changed files with 207 additions and 131 deletions

Binary file not shown.

View File

@ -165,19 +165,18 @@ DIR.DA jsr SRC.GetNextCharNB
.8 clc
rts
*---------------------------------------
DIR.DO ldy #ASM.DO.Count
lda (pData),y
DIR.DO >LDA.G ASM.DO.Count
inc
cmp #SRC.DO.MAXDEPTH
bcs .98
jsr SRC.GetNextCharNB
bcs .99
jsr EXP.Eval
bcs .99
ldy #ASM.DO.Count
lda (pData),y
inc
sta (pData),y
>INC.G ASM.DO.Count
* clc ok from bcs .99
adc #ASM.DOELSE.Flag-1
tay
@ -189,8 +188,7 @@ DIR.DO ldy #ASM.DO.Count
sta (pData),y
lda #$FF
ldy #ASM.DO.ON
sta (pData),y
>STA.G ASM.DO.ON
clc
rts
@ -257,6 +255,8 @@ DIR.EQ >LDA.G SYM.bGlobal
jsr SYM.UpdateGlobalAcc
bcs .9
lda #1
>STA.G OUT.bEquate
clc
rts
@ -288,20 +288,40 @@ DIR.HS jsr SRC.GetNextCharNB
jsr SRC.IsDigit16
bcs .99
.1 asl
.1 >STA.G DIR.Byte
jsr SRC.GetNextChar
bcc .2
jmp OUT.EmitByte
.2 jsr SRC.IsDigit16
bcc .3
cmp #','
beq .22
cmp #'.'
bne .99
.22 >LDA.G DIR.Byte
jsr OUT.EmitByte
bcc .5
rts
.3 pha
>LDA.G DIR.Byte
asl
asl
asl
asl
>STA.G DIR.Byte
jsr SRC.GetNextChar
bcs .99
jsr SRC.IsDigit16
bcs .99
pla
>ORA.G DIR.Byte
jsr OUT.EmitByte
.4 jsr OUT.EmitByte
bcs .9
jsr SRC.GetNextChar
@ -313,12 +333,12 @@ DIR.HS jsr SRC.GetNextCharNB
bcc .1
cmp #','
beq .2
beq .5
cmp #'.'
bne .99
.2 jsr SRC.GetNextChar
.5 jsr SRC.GetNextChar
bcs .99
jsr SRC.IsDigit16
bcc .1
@ -361,7 +381,7 @@ DIR.LI jsr SRC.GetNextChar
>LDYA L.T.LI
jsr SRC.GetKeyword
bcs .9
jsr .7
jsr SRC.GetChar
@ -440,10 +460,9 @@ DIR.MA >LDA.G MAC.bAdd
rts
*---------------------------------------
DIR.OP jsr SRC.GetNextCharNB
beq DIR.OP.SYNERR
bcs DIR.OP.SYNERR
>LDYA ZPLinePtr
jmp FIO.LOAD.ASM.T
DIR.OP.SYNERR lda #ERR.SYNTAX.ERROR

View File

@ -10,10 +10,13 @@ AUTO 4,1
* & = octal
* * = PC
*---------------------------------------
EXP.Eval stz EXP.Operator
EXP.Eval lda #2
sta SRC.ACC.SIZE Assume WORD (2 bytes)
stz EXP.Modifier
stz EXP.Operator
jsr SRC.GetChar
bcs EXP.Eval.Missing
@ -216,9 +219,31 @@ EXP.OP.ORA
*---------------------------------------
EXP.OP.AND
*---------------------------------------
EXP.OP.LOW
EXP.OP.LOW clc
rts
*---------------------------------------
EXP.OP.EQU
EXP.OP.EQU ldx #0 ARG-ACC->ACC
ldy #4
clc il not Equals, return 0
.1 lda SRC.ARG,x
eor SRC.ACC,x
bne .2
inx
dey
bne .1
sec equals, return 1
.2 lda #0
rol
sta SRC.ACC
lda #1
sta SRC.ACC.SIZE
.9 rts
*---------------------------------------
EXP.OP.GRT
clc

View File

@ -23,6 +23,120 @@ OUT.Reset ldx #4
bne .2
>STZ.G OUT.Buf
>STA.G OUT.bEquate
rts
*---------------------------------------
OUT.PrintLineErr >STA.G DIR.Byte Save Error code
jsr OUT.PrintLine.1
bcs .9
.1 >PUSHB.G DIR.Byte
>LDYA L.MSG.ERROR
>SYSCALL PrintF.YA
ldx ZPLinePtr
cpx ZPLineBuf
beq .4
.3 phx
lda #'-'
>SYSCALL PutChar.A
plx
bcs .9
dex
cpx ZPLineBuf
bne .3
.4 lda #'^'
phy
>SYSCALL PutChar.A
ply
bcs .9
.5 lda #13
>SYSCALL PutChar.A
lda #10
>SYSCALL PutChar.A
.9 rts
*---------------------------------------
OUT.PrintLine jsr OUT.PrintLineOn
bcs OUT.PrintLine.9
OUT.PrintLine.1 jsr OUT.PrintLineOutBuf
bcs OUT.PrintLine.9
>PUSHW ZPLineBuf
>PUSHW.G SRC.LINENUM
>LDYA L.MSG.SRCLINE
>SYSCALL PrintF.YA
OUT.PrintLine.9 rts
*---------------------------------------
OUT.PrintLineOn >LDA.G ASM.LI.ON
bpl .9
>LDA.G MAC.bAdd
bpl .1
>LDA.G ASM.LI.MON
bpl .9
bmi .8
.1
.8 clc
rts
.9 sec
rts
*---------------------------------------
OUT.PrintLineOutBuf >LDA.G OUT.bEquate
bne OUT.PrintLineAcc
>LDA.G OUT.Buf
beq .2
tax
clc
adc #OUT.Buf
tay
.1 >PUSHB (pData),y
dey
dex
bne .1
.2 ldy #OUT.PC+1
>PUSHB (pData),y
dey
>PUSHB (pData),y
>LDA.G OUT.Buf
asl
tax
ldy L.MSG.OUT0,x
lda L.MSG.OUT0+1,x
>SYSCALL PrintF.YA
rts
OUT.PrintLineAcc ldx SRC.ACC.SIZE
beq .2
ldy #0
.1 >PUSHB SRC.ACC,y
iny
dex
bne .1
.2 lda SRC.ACC.SIZE
asl
tax
ldy L.MSG.EQU0,x
lda L.MSG.EQU0+1,x
>SYSCALL PrintF.YA
rts
*---------------------------------------
OUT.EmitByte pha
@ -31,12 +145,12 @@ OUT.EmitByte pha
cmp #3
bne .2
jsr SRC.PrintLineOn
jsr OUT.PrintLineOn
bcs .1
>LDA.G ASM.LI.XON
bpl .1
jsr SRC.PrintLineOutBuf
jsr OUT.PrintLineOutBuf
lda #13
>SYSCALL PutChar.A
lda #10

View File

@ -2,99 +2,6 @@ NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
*---------------------------------------
SRC.PrintLine jsr SRC.PrintLineOn
bcs SRC.PrintLine.9
SRC.PrintLine.1 jsr SRC.PrintLineOutBuf
bcs SRC.PrintLine.9
>PUSHW ZPLineBuf
>PUSHW.G SRC.LINENUM
>LDYA L.MSG.SRCLINE
>SYSCALL PrintF.YA
SRC.PrintLine.9 rts
*---------------------------------------
SRC.PrintLineOn >LDA.G ASM.LI.ON
bpl .9
>LDA.G MAC.bAdd
bpl .1
>LDA.G ASM.LI.MON
bpl .9
bmi .8
.1
.8 clc
rts
.9 sec
rts
*---------------------------------------
SRC.PrintLineOutBuf >LDA.G OUT.Buf
beq .2
tax
clc
adc #OUT.Buf
tay
.1 >PUSHB (pData),y
dey
dex
bne .1
.2 ldy #OUT.PC+1
>PUSHB (pData),y
dey
>PUSHB (pData),y
>LDA.G OUT.Buf
asl
tax
ldy L.MSG.OUT0,x
lda L.MSG.OUT0+1,x
>SYSCALL PrintF.YA
.9 rts
*---------------------------------------
SRC.PrintLineErr >STA.G DIR.Byte Save Error code
jsr SRC.PrintLineOn
bcc .1 Already printed
jsr SRC.PrintLine.1
bcs .9
.1 >PUSHB.G DIR.Byte
>LDYA L.MSG.ERROR
>SYSCALL PrintF.YA
ldx ZPLinePtr
cpx ZPLineBuf
beq .4
.3 phx
lda #'-'
>SYSCALL PutChar.A
plx
bcs .9
dex
cpx ZPLineBuf
bne .3
.4 lda #'^'
phy
>SYSCALL PutChar.A
ply
bcs .9
.5 lda #13
>SYSCALL PutChar.A
lda #10
>SYSCALL PutChar.A
.9 rts
*---------------------------------------
SRC.ParseLine jsr SRC.GetChar
bcs .8
@ -217,7 +124,6 @@ SRC.ParseLine.Macro >LDA.G ASM.PASS If Pass#2, ignore
SRC.ParseLine.RTS rts
*---------------------------------------
SRC.ParseLine.LABEL lda #0
sta (ZPLocalBuf)
>STA.G SYM.bGlobal
jsr SRC.GetChar
@ -245,7 +151,9 @@ SRC.ParseLine.LABEL lda #0
.1 lda #$ff
>STA.G SYM.bGlobal
inc
sta (ZPLocalBuf)
>LDA.G ASM.PASS
bne .3
@ -267,8 +175,7 @@ SRC.ParseLine.LABEL lda #0
.3 jsr SYM.LookupGlobal Pass #2: should be already defined...
bcs SRC.ParseLine.Undef
jsr SYM.UpdateGlobalPC
jsr SYM.UpdateGlobalPC
*---------------------------------------
SRC.ParseLine.DirOp jsr SRC.GetNextCharNB Scan for an Opcode...
bcs SRC.ParseLine.Ok

View File

@ -81,6 +81,11 @@ L.MSG.OUT0 .DA MSG.OUT0
.DA MSG.OUT1
.DA MSG.OUT2
.DA MSG.OUT3
L.MSG.EQU0 .DA MSG.EQU0
.DA MSG.EQU1
.DA MSG.EQU2
.DA MSG.EQU3
.DA MSG.EQU4
L.MSG.SRCLINE .DA MSG.SRCLINE
L.MSG.ERROR .DA MSG.ERROR
L.MSG.SYMBOLS .DA MSG.SYMBOLS
@ -273,13 +278,13 @@ CS.RUN >SYSCALL GetChar
.2 jsr SRC.ParseLine
bcs .9
jsr SRC.PrintLine
jsr OUT.PrintLine
.8 clc
rts
.9 pha
jsr SRC.PrintLineErr
jsr OUT.PrintLineErr
pla
sec
rts
@ -382,11 +387,16 @@ MSG.PASS >CSTR "Pass:#%d\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.T.FILE >CSTR "Loading CPU File:%s\r\n"
MSG.OUT0 >CSTR "%H- "
MSG.OUT1 >CSTR "%H-%h "
MSG.OUT2 >CSTR "%H-%h %h "
MSG.OUT3 >CSTR "%H-%h %h %h "
MSG.SRCLINE >CSTR "%05D %s\r\n"
MSG.OUT0 >CSTR "%H- "
MSG.OUT1 >CSTR "%H-%h "
MSG.OUT2 >CSTR "%H-%h %h "
MSG.OUT3 >CSTR "%H-%h %h %h"
MSG.EQU0 >CSTR "[ ]"
MSG.EQU1 >CSTR "[ %h]"
MSG.EQU2 >CSTR "[ %h%h]"
MSG.EQU3 >CSTR "[ %h%h%h]"
MSG.EQU4 >CSTR "[ %h%h%h%h]"
MSG.SRCLINE >CSTR " %05D %s\r\n"
MSG.ERROR >CSTR "*** Fatal Error $%h "
MSG.SYMBOLS >CSTR "Symbol Table:\r\n"
MSG.GSYMBOL >CSTR "$%h%h%h%h:%S\r\n"
@ -463,6 +473,7 @@ MAC.bAdd .BS 1
OUT.PC .BS 4
OUT.Buf .BS 4
OUT.bEquate .BS 1
DS.END .ED
*---------------------------------------