mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-25 05:32:20 +00:00
733 lines
11 KiB
Plaintext
733 lines
11 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*---------------------------------------
|
||
DIR.Reset lda #$ff
|
||
>STA.G ASM.LI.ON
|
||
iny #ASM.LI.CON
|
||
sta (pData),y
|
||
iny #ASM.LI.MON
|
||
sta (pData),y
|
||
iny #ASM.LI.XON
|
||
sta (pData),y
|
||
|
||
>STA.G MAC.StkPtr
|
||
|
||
rts
|
||
*---------------------------------------
|
||
DIR.AC clc
|
||
rts
|
||
*---------------------------------------
|
||
DIR.AT sec
|
||
.HS 90 BCC
|
||
*---------------------------------------
|
||
DIR.AS clc
|
||
lda #0
|
||
ror
|
||
sta DIR.Byte Save b7 of last char in string
|
||
jsr SRC.GetNextChar
|
||
bcs .9
|
||
|
||
cmp #'-'
|
||
bne .1
|
||
|
||
lda #$40 save b7 status of ALL chars
|
||
tsb DIR.Byte
|
||
|
||
jsr SRC.GetNextChar
|
||
bcs .9
|
||
|
||
.1 sta DIR.Word Save delimiter....
|
||
sta DIR.Word+1 Save also in prev char..
|
||
|
||
.2 jsr SRC.GetNextChar
|
||
bcs .8
|
||
|
||
cmp DIR.Word delimiter ?
|
||
beq .8
|
||
|
||
ldx DIR.Word+1 Get prev char
|
||
sta DIR.Word+1 replace it with new
|
||
txa
|
||
cmp DIR.Word is it the starting delimiter
|
||
beq .2 yes, skip
|
||
|
||
bit DIR.Byte
|
||
bvc .3
|
||
|
||
ora #$80
|
||
|
||
.3 jsr OUT.EmitByte no, emit prev char
|
||
bcc .2
|
||
|
||
.9 lda #E.SYNTAX.ERROR
|
||
sec
|
||
rts
|
||
|
||
.8 lda DIR.Word+1 Get prev char
|
||
cmp DIR.Word someone typed .AS "" ?
|
||
beq .88
|
||
|
||
bit DIR.Byte
|
||
bpl .81
|
||
|
||
eor #$80
|
||
|
||
.81 jmp OUT.EmitByte
|
||
|
||
.88 clc
|
||
DIR.AS.RTS rts
|
||
*---------------------------------------
|
||
DIR.AZ jsr DIR.AS
|
||
bcs DIR.AS.RTS
|
||
lda #0
|
||
jmp OUT.EmitByte
|
||
*---------------------------------------
|
||
DIR.BS jsr SRC.GetNextCharNB
|
||
bcs .98
|
||
|
||
jsr EXP.ResetAcc
|
||
|
||
jsr EXP.Eval
|
||
bcs .9
|
||
|
||
lda SRC.ACC+3
|
||
ora SRC.ACC+2
|
||
bne .99
|
||
|
||
lda SRC.ACC
|
||
eor #$ff
|
||
sta DIR.Word
|
||
|
||
lda SRC.ACC+1
|
||
eor #$ff
|
||
sta DIR.Word+1
|
||
|
||
stz DIR.Byte
|
||
jsr SRC.GetChar
|
||
bcs .1
|
||
|
||
cmp #C.SPACE
|
||
beq .1
|
||
|
||
cmp #','
|
||
bne .98
|
||
|
||
jsr EXP.ResetAcc
|
||
|
||
jsr EXP.Eval
|
||
bcs .9
|
||
|
||
lda SRC.ACC+3
|
||
ora SRC.ACC+2
|
||
ora SRC.ACC+1
|
||
bne .99
|
||
|
||
lda SRC.ACC
|
||
sta DIR.Byte
|
||
|
||
.1 inc DIR.Word
|
||
bne .2
|
||
inc DIR.Word+1
|
||
beq .8
|
||
|
||
.2 lda DIR.Byte
|
||
jsr OUT.EmitByte
|
||
bcc .1
|
||
rts
|
||
|
||
.8 clc
|
||
.9 rts
|
||
|
||
.99 lda #E.RANGE
|
||
sec
|
||
rts
|
||
|
||
.98 lda #E.SYNTAX.ERROR
|
||
sec
|
||
rts
|
||
*---------------------------------------
|
||
DIR.DA jsr SRC.GetNextCharNB
|
||
bcs .98
|
||
|
||
.1 jsr EXP.ResetAcc
|
||
|
||
jsr EXP.Eval
|
||
bcs .9
|
||
|
||
ldy #0
|
||
ldx SRC.ACC.SIZE
|
||
|
||
.2 lda SRC.ACC,y
|
||
jsr OUT.EmitByte
|
||
bcs .9
|
||
|
||
iny
|
||
dex
|
||
bne .2
|
||
|
||
.3 jsr SRC.GetChar
|
||
bcs .8
|
||
|
||
cmp #C.SPACE
|
||
beq .8
|
||
|
||
cmp #','
|
||
bne .98
|
||
|
||
jsr SRC.GetNextChar
|
||
bcc .1
|
||
|
||
.98 lda #E.SYNTAX.ERROR
|
||
sec
|
||
.9 rts
|
||
|
||
.8 clc
|
||
rts
|
||
*---------------------------------------
|
||
DIR.DO >LDA.G ASM.DO.StackPtr
|
||
tay
|
||
inc
|
||
cmp #DO.MAXDEPTH
|
||
bcs .98
|
||
|
||
tya
|
||
beq .1
|
||
|
||
* clc
|
||
adc #ASM.DO.Stack-1
|
||
tay
|
||
|
||
lda (pData),y Previous DO is false?
|
||
bne .1
|
||
|
||
>INC.G ASM.DO.StackPtr yes,stack FALSE
|
||
|
||
* clc
|
||
adc #ASM.DO.Stack-1
|
||
tay
|
||
lda #0
|
||
bra .8
|
||
|
||
.1 jsr SRC.GetNextCharNB
|
||
bcs .99
|
||
|
||
jsr EXP.ResetAcc
|
||
|
||
jsr EXP.Eval
|
||
bcs .99
|
||
|
||
>INC.G ASM.DO.StackPtr
|
||
* clc
|
||
adc #ASM.DO.Stack-1
|
||
tay
|
||
lda SRC.ACC
|
||
ora SRC.ACC+1
|
||
ora SRC.ACC+2
|
||
ora SRC.ACC+3
|
||
beq .8
|
||
lda #$ff
|
||
|
||
.8 sta (pData),y
|
||
|
||
clc
|
||
rts
|
||
|
||
.98 lda #E.TOO.MANY.DO
|
||
sec
|
||
.99 rts
|
||
*---------------------------------------
|
||
DIR.EL >LDA.G ASM.DO.StackPtr
|
||
beq .9
|
||
|
||
tax
|
||
dec
|
||
beq .1 no previous DO context
|
||
|
||
clc
|
||
adc #ASM.DO.Stack-1
|
||
tay
|
||
lda (pData),y
|
||
beq .8 previous is FALSE
|
||
|
||
.1 txa
|
||
clc
|
||
adc #ASM.DO.Stack-1
|
||
tay
|
||
lda (pData),y
|
||
eor #$ff
|
||
sta (pData),y
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.9 lda #E.ELSE.WITHOUT.DO
|
||
sec
|
||
rts
|
||
*---------------------------------------
|
||
DIR.EM lda #E.MACRO.INV.DEF
|
||
sec
|
||
rts
|
||
*---------------------------------------
|
||
DIR.DU >LDA.G ASM.DU.ON
|
||
bmi DIR.EP.ILLEGAL
|
||
|
||
lda #$80
|
||
sta (pData),y
|
||
|
||
ldy #ASM.PC.DU
|
||
jmp DIR.SavePC
|
||
*---------------------------------------
|
||
DIR.PH >LDA.G ASM.PH.ON
|
||
bmi DIR.EP.ILLEGAL
|
||
|
||
lda #$80
|
||
sta (pData),y
|
||
ldy #ASM.PC.PH
|
||
jsr DIR.SavePC
|
||
|
||
jmp DIR.OR
|
||
*---------------------------------------
|
||
DIR.ED >LDA.G ASM.DU.ON
|
||
bpl DIR.EP.ILLEGAL
|
||
|
||
lda #0
|
||
sta (pData),y
|
||
|
||
ldy #ASM.PC.DU
|
||
jmp DIR.RestorePC
|
||
*---------------------------------------
|
||
DIR.EP >LDA.G ASM.PH.ON
|
||
bpl .9
|
||
|
||
lda #0
|
||
sta (pData),y
|
||
ldy #ASM.PC.PH
|
||
jmp DIR.RestorePC
|
||
.9
|
||
DIR.EP.ILLEGAL lda #E.ILLEGAL.DIR
|
||
sec
|
||
DIR.EP.RTS rts
|
||
*---------------------------------------
|
||
DIR.SE sec
|
||
.HS 90 BCC
|
||
*---------------------------------------
|
||
DIR.EQ clc
|
||
|
||
lda #$ff
|
||
>STA.G OUT.bEquate
|
||
|
||
>LDA.G SYM.BufPtr
|
||
beq DIR.EP.ILLEGAL not in global symbol context
|
||
|
||
eor #SYMG
|
||
beq .1
|
||
|
||
bcs DIR.EP.ILLEGAL .SE not allowed in local/private
|
||
bcc .10 .EQ in local, skip F update
|
||
|
||
.1 ror A = 0 : CS = SYMG.F.RW
|
||
|
||
ora #SYMG.F.EQU
|
||
sta SRC.ACC.F
|
||
|
||
.10 jsr SRC.GetNextCharNB
|
||
bcs .9
|
||
|
||
jsr EXP.ResetAccV keep F
|
||
|
||
jsr EXP.Eval
|
||
bcs DIR.EP.RTS
|
||
|
||
>LDA.G SYM.BufPtr
|
||
|
||
cmp #SYMG
|
||
beq .12
|
||
|
||
tay
|
||
ldx #3 we are in local/private
|
||
|
||
.11 lda SRC.ACC,x update value
|
||
dey
|
||
sta (ZPSymbolBuf),y
|
||
dex
|
||
bpl .11
|
||
|
||
clc
|
||
rts
|
||
|
||
.12 ldy #SYMG-1
|
||
|
||
.13 lda SRC.ACC.F,y
|
||
sta (ZPSymbolBuf),y
|
||
dey
|
||
bpl .13
|
||
|
||
>LDA.G ASM.PASS
|
||
bne .2
|
||
|
||
jmp SYM.StoreGlobal
|
||
|
||
.2 jmp SYM.UpdateGlobal
|
||
|
||
.9 lda #E.SYNTAX.ERROR
|
||
sec
|
||
rts
|
||
*---------------------------------------
|
||
DIR.FI >LDA.G ASM.DO.StackPtr
|
||
beq DIR.EP.ILLEGAL
|
||
|
||
dec
|
||
sta (pData),y
|
||
|
||
clc
|
||
rts
|
||
*---------------------------------------
|
||
DIR.HS jsr SRC.GetNextCharNB
|
||
bcs .99
|
||
|
||
jsr SRC.IsDigit16
|
||
bcs .99
|
||
|
||
.1 sta DIR.Byte
|
||
jsr SRC.GetNextChar
|
||
bcc .2
|
||
|
||
jmp OUT.EmitByte
|
||
|
||
.2 jsr SRC.IsDigit16
|
||
bcc .3
|
||
|
||
cmp #','
|
||
beq .22
|
||
|
||
cmp #'.'
|
||
bne .99
|
||
|
||
.22 lda DIR.Byte
|
||
jsr OUT.EmitByte
|
||
bcc .5
|
||
rts
|
||
|
||
.3 pha
|
||
lda DIR.Byte
|
||
asl
|
||
asl
|
||
asl
|
||
asl
|
||
sta DIR.Byte
|
||
pla
|
||
ora DIR.Byte
|
||
|
||
.4 jsr OUT.EmitByte
|
||
bcs .9
|
||
|
||
jsr SRC.GetNextChar
|
||
bcs .8
|
||
|
||
cmp #C.SPACE
|
||
beq .8
|
||
|
||
jsr SRC.IsDigit16
|
||
bcc .1
|
||
|
||
cmp #','
|
||
beq .5
|
||
|
||
cmp #'.'
|
||
bne .99
|
||
|
||
.5 jsr SRC.GetNextChar
|
||
bcs .99
|
||
|
||
jsr SRC.IsDigit16
|
||
bcc .1
|
||
|
||
.99 lda #E.SYNTAX.ERROR
|
||
sec
|
||
.9 rts
|
||
|
||
.8 clc
|
||
rts
|
||
*---------------------------------------
|
||
DIR.IN jsr SRC.GetNextCharNB
|
||
bcs .9
|
||
|
||
>LDYA ZPLinePtr
|
||
jmp FIO.OpenFile
|
||
|
||
.9 lda #E.SYNTAX.ERROR
|
||
sec
|
||
rts
|
||
*---------------------------------------
|
||
DIR.LI jsr SRC.GetNextChar
|
||
bcs .9
|
||
|
||
>LDYA L.T.LI
|
||
jsr SRC.GetKeyword
|
||
bcs .9
|
||
jsr .7
|
||
|
||
jsr SRC.GetChar
|
||
bcs .8
|
||
cmp #','
|
||
beq DIR.LI
|
||
|
||
cmp #C.SPACE
|
||
beq .8
|
||
|
||
.9 lda #E.SYNTAX.ERROR
|
||
sec
|
||
rts
|
||
|
||
.7 jmp (J.LI,x)
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
DIR.LI.ON ldy #ASM.LI.ON
|
||
sec
|
||
bra DIR.LI.APPLY
|
||
|
||
DIR.LI.OFF ldy #ASM.LI.ON
|
||
clc
|
||
bra DIR.LI.APPLY
|
||
|
||
DIR.LI.CON ldy #ASM.LI.CON
|
||
sec
|
||
bra DIR.LI.APPLY
|
||
|
||
DIR.LI.COFF ldy #ASM.LI.CON
|
||
clc
|
||
bra DIR.LI.APPLY
|
||
|
||
DIR.LI.MON ldy #ASM.LI.MON
|
||
sec
|
||
bra DIR.LI.APPLY
|
||
|
||
DIR.LI.MOFF ldy #ASM.LI.MON
|
||
clc
|
||
bra DIR.LI.APPLY
|
||
|
||
DIR.LI.XON ldy #ASM.LI.XON
|
||
sec
|
||
bra DIR.LI.APPLY
|
||
|
||
DIR.LI.XOFF ldy #ASM.LI.XON
|
||
clc
|
||
DIR.LI.APPLY lda #0
|
||
ror
|
||
|
||
sta (pData),y
|
||
rts
|
||
*---------------------------------------
|
||
DIR.MA >LDA.G ASM.MA.ON
|
||
bmi .9
|
||
|
||
>LDA.G ASM.PASS If Pass#2, ignore
|
||
bne .8
|
||
|
||
jsr SRC.GetNextCharNB
|
||
beq DIR.OP.SYNERR
|
||
|
||
>PUSHB.G MAC.hList
|
||
>PUSHW ZPLinePtr
|
||
>SYSCALL SListNewKey
|
||
bcs .99
|
||
|
||
>STYA.G MAC.ID
|
||
|
||
.8 lda #$ff
|
||
>STA.G ASM.MA.ON
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.MACRO.INV.DEF
|
||
sec
|
||
.99 rts
|
||
*---------------------------------------
|
||
DIR.OP jsr SRC.GetNextCharNB
|
||
bcs DIR.OP.SYNERR
|
||
>LDYA ZPLinePtr
|
||
|
||
jmp FIO.LOAD.CPU
|
||
|
||
DIR.OP.SYNERR lda #E.SYNTAX.ERROR
|
||
sec
|
||
rts
|
||
*---------------------------------------
|
||
DIR.OR jsr SRC.GetNextCharNB
|
||
bcs DIR.OP.SYNERR
|
||
|
||
jsr EXP.ResetAcc
|
||
|
||
jsr EXP.Eval
|
||
bcs .9
|
||
|
||
ldx #0
|
||
ldy #ASM.PC
|
||
|
||
.1 lda SRC.ACC,x
|
||
sta (pData),y
|
||
iny
|
||
inx
|
||
cpx #4
|
||
bne .1
|
||
|
||
>LDA.G ASM.DU.ON
|
||
bmi .8
|
||
|
||
>LDA.G ASM.PH.ON
|
||
bmi .8
|
||
|
||
lda SRC.ACC
|
||
>STA.G DST.AUXTYPE
|
||
lda SRC.ACC+1
|
||
iny
|
||
sta (pData),y
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*---------------------------------------
|
||
DIR.EN
|
||
*---------------------------------------
|
||
DIR.PG
|
||
*---------------------------------------
|
||
DIR.TI
|
||
*---------------------------------------
|
||
DIR.US
|
||
*---------------------------------------
|
||
DIR.TA
|
||
|
||
DIR.TA.8 clc
|
||
DIR.TA.RTS rts
|
||
*---------------------------------------
|
||
DIR.TF >LDA.G ASM.PASS If Pass#1, ignore
|
||
beq DIR.TA.8
|
||
|
||
>LDA.G ArgDstFile
|
||
beq .1
|
||
|
||
>SYSCALL ArgV
|
||
bra .2
|
||
|
||
.1 jsr SRC.GetNextCharNB
|
||
bcs DIR.OP.SYNERR
|
||
|
||
>LDYA ZPLinePtr
|
||
|
||
.2 >SYSCALL StrDup
|
||
bcs DIR.TA.RTS
|
||
>STYA ZPPtr1
|
||
stx ZPPtr2
|
||
|
||
lda #S.FI.T.BIN
|
||
sta ZPPtr2+1
|
||
|
||
ldy #$ff
|
||
|
||
.3 iny
|
||
lda (ZPPtr1),y
|
||
beq .7
|
||
cmp #','
|
||
bne .3
|
||
|
||
lda #0
|
||
sta (ZPPtr1),y
|
||
|
||
iny
|
||
lda (ZPPtr1),y
|
||
cmp #'T'
|
||
beq .4
|
||
|
||
.30 lda #E.SYNTAX.ERROR
|
||
bra .9
|
||
|
||
.4 ldx #0
|
||
|
||
.5 iny
|
||
lda (ZPPtr1),y
|
||
cmp DIR.SYS,x including \0
|
||
bne .30
|
||
inx
|
||
cpx #4
|
||
bne .5
|
||
|
||
lda #S.FI.T.SYS
|
||
sta ZPPtr2+1
|
||
|
||
.7 >PUSHW ZPPtr1
|
||
>PUSHWZ Allocate
|
||
>SYSCALL RealPath
|
||
bcs .9
|
||
|
||
txa
|
||
>STA.G DST.hFILENAME
|
||
>SYSCALL GetMemPtr
|
||
>PUSHYA
|
||
>PUSHBI O.WRONLY+O.CREATE
|
||
>PUSHB ZPPtr2+1 Type
|
||
>PUSHW.G DST.AUXTYPE
|
||
>SYSCALL FOpen
|
||
bcs .9
|
||
|
||
>STA.G DST.hREFNUM
|
||
|
||
clc
|
||
|
||
.9 php
|
||
pha
|
||
lda ZPPtr2
|
||
>SYSCALL FreeMem
|
||
pla
|
||
plp
|
||
|
||
rts
|
||
*---------------------------------------
|
||
DIR.SavePC phy
|
||
plx
|
||
ldy #ASM.PC+3
|
||
|
||
.1 lda (pData),y
|
||
pha
|
||
dey
|
||
cpy #ASM.PC-1
|
||
bne .1
|
||
|
||
phx
|
||
ply
|
||
ldx #3
|
||
|
||
.2 pla
|
||
sta (pData),y
|
||
iny
|
||
dex
|
||
bpl .2
|
||
|
||
clc
|
||
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
|
||
|
||
clc because of JMP to it
|
||
rts
|
||
*---------------------------------------
|
||
MAN
|
||
SAVE usr/src/bin/asm.s.dir
|
||
LOAD usr/src/bin/asm.s
|
||
ASM
|