A2osX/BIN/ASM.S.EXP.txt
2018-11-17 18:17:13 +01:00

403 lines
6.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
PREFIX
AUTO 4,1
*---------------------------------------
* EXP.Modifiers:
* # : 8b,Byte 1
* / : 8b,Byte 2
* ^ : 8b,Byte 3
* < : 24b,Byte 1,2,3
* > : 32b
*---------------------------------------
* Num Format : 0-9 -> decimal
* $ = Hex
* % = binary
* & = octal
* * = PC
*---------------------------------------
EXP.Eval.Missing
lda #ERR.MISSING.EXP
sec
rts
EXP.Eval >STZ.G EXP.Modifier
>STZ.G EXP.Prefix
>STZ.G EXP.Operator
jsr SRC.GetChar
bcs EXP.Eval.Missing
jsr SRC.IsMODReserved
bcs EXP.Eval.Next
txa
>STA.G EXP.Modifier
lda #'#'
>STA.G EXP.Prefix
EXP.Eval.Next0 jsr SRC.GetNextChar
EXP.Eval.Next lda #2
sta SRC.ACC.SIZE Default To WORD (2 bytes)
stz SRC.ACC
stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
jsr SRC.GetChar
bcs EXP.Eval.Missing
cmp #'.' Local Label?
bne .12
jsr EXP.GetSymL
bcs .14
jmp EXP.EvalOperator
.14 rts
.12 cmp #'*'
bne .10
ldy #ASM.PC+3
ldx #3
.11 lda (pData),y
sta SRC.ACC,x
dey
dex
bpl .11
jsr SRC.GetNextChar
jmp EXP.EvalOperator
.10 jsr SRC.IsDigit10 Decimal constant ?
bcs .1
jsr SRC.GetDecimal
bcs EXP.EvalExitRTS
bra EXP.EvalOperator
.1 cmp #'$' Hex?
bne .2
jsr SRC.GetHex
bcs EXP.EvalExitRTS
bra EXP.EvalOperator
.2 cmp #'%' binary?
bne .3
jsr SRC.GetBinary
bcs EXP.EvalExitRTS
bra EXP.EvalOperator
.3 cmp #'&' octal?
bne .4
jsr SRC.GetOctal
bcs EXP.EvalExitRTS
bra EXP.EvalOperator
.4 cmp #'''
bne .43
jsr SRC.GetNextChar
bcs EXP.EvalExitSYN
jsr EXP.SetAccA
jsr SRC.GetNextChar
bcs EXP.EvalOperator
cmp #'''
bne EXP.EvalExitSYN
jsr SRC.GetNextChar
bra EXP.EvalOperator
.43 cmp #'"'
bne .42
jsr SRC.GetNextChar
bcs EXP.EvalExitSYN
ora #$80
jsr EXP.SetAccA
jsr SRC.GetNextChar
bcs EXP.EvalOperator
cmp #'"'
bne EXP.EvalExitSYN
jsr SRC.GetNextChar
bra EXP.EvalOperator
.42 jsr SRC.IsLetter Symbol ?
bcs EXP.EvalExitSYN
jsr EXP.GetSymG
bcs EXP.EvalExitUND
bra EXP.EvalOperator
EXP.EvalExitOK >LDA.G EXP.Modifier
beq .8
asl
tax
jmp (J.EXP.MOD-2,x)
.8 clc
EXP.EvalExitRTS rts
EXP.EvalExitSYN lda #ERR.SYNTAX.ERROR
sec
rts
EXP.EvalExitUND lda #ERR.UNDEF.SYMBOL
sec
rts
*---------------------------------------
EXP.EvalOperator
>LDA.G EXP.Operator
beq .7
jsr EXP.Compute
bcs EXP.EvalExitRTS
.7 jsr SRC.GetChar
bcs EXP.EvalExitOK
cmp #' '
beq EXP.EvalExitOK
jsr SRC.IsAMReserved
bcc EXP.EvalExitOK
jsr SRC.IsEXPReserved
bcs EXP.EvalExitSYN
txa
>STA.G EXP.Operator
ldx #4
.8 lda SRC.ACC.SIZE,x
sta SRC.ARG.SIZE,x
dex
bpl .8
jmp EXP.Eval.Next0
*---------------------------------------
EXP.GetSymL jsr SRC.GetNextChar
bcs .9
jsr SRC.GetDecimal
bcs EXP.EvalExitSYN
lda SRC.ACC+1
ora SRC.ACC+2
ora SRC.ACC+3
bne EXP.EvalExitSYN Max .255
lda SRC.ACC
beq EXP.EvalExitSYN .0 is not allowed
jsr SYM.LookupLocal
bcc .8
>LDA.G ASM.PASS pass#2?
bne EXP.EvalExitUND
lda #0 Mark ACC as pending
sta SRC.ACC.SIZE
clc
rts
.9 lda #ERR.SYNTAX.ERROR
sec
.8 rts
*---------------------------------------
EXP.GetSymG jsr SYM.LookupGlobal
bcs .2
jsr SYM.Lookup2Acc
clc
rts
.2 >LDA.G ASM.PASS pass#2?
bne EXP.EvalExitUND yes, undefined symbol
lda #0 Mark ACC as pending
sta SRC.ACC.SIZE
.3 jsr SRC.GetNextChar
bcs .8
jsr SRC.IsLetterOrDigit
bcc .3
cmp #'.'
beq .3
cmp #'_'
beq .3
.8 clc
rts
.99 lda #ERR.UNDEF.SYMBOL
sec
.9 rts
*---------------------------------------
EXP.MOD.8.3 lda SRC.ACC+2
bra EXP.MOD.8
EXP.MOD.8.2 lda SRC.ACC+1
EXP.MOD.8 sta SRC.ACC
EXP.MOD.8.1 lda #1
sta SRC.ACC.SIZE
clc
rts
EXP.MOD.24 lda #3
sta SRC.ACC.SIZE
clc
rts
EXP.MOD.32 lda #4
sta SRC.ACC.SIZE
clc
rts
*---------------------------------------
EXP.Compute ldx SRC.ACC.SIZE
beq .1
ldx SRC.ARG.SIZE
beq .1
asl
tax
jmp (J.EXP.OP-2,x)
.1 >LDA.G ASM.PASS
beq .8
lda #ERR.UNDEF.SYMBOL
sec
rts
.8 clc
rts
*---------------------------------------
EXP.OP.EOR ldx #3
.1 lda SRC.ARG,x
eor SRC.ACC,x
sta SRC.ACC,x
dex
bpl .1
rts
*---------------------------------------
EXP.OP.ORA ldx #3
.1 lda SRC.ARG,x
ora SRC.ACC,x
sta SRC.ACC,x
dex
bpl .1
rts
*---------------------------------------
EXP.OP.AND ldx #3
.1 lda SRC.ARG,x
and SRC.ACC,x
sta SRC.ACC,x
dex
bpl .1
rts
*---------------------------------------
EXP.OP.LOW jsr EXP.OP.SUB
lda #0
rol
jmp EXP.SetAccA
*---------------------------------------
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 jsr EXP.OP.SUB
lda #0
rol
eor #1
jmp EXP.SetAccA
*---------------------------------------
EXP.OP.ADD ldx #0 ARG-ACC->ACC
ldy #4
clc
.1 lda SRC.ARG,x
adc SRC.ACC,x
sta SRC.ACC,x
inx
dey
bne .1
bcc .8
lda #ERR.VAL.TOO.BIG
.8 rts
*---------------------------------------
EXP.OP.SUB ldx #0 ARG-ACC->ACC
ldy #4
sec
.1 lda SRC.ARG,x
sbc SRC.ACC,x
sta SRC.ACC,x
inx
dey
bne .1
bcs .8
lda #ERR.VAL.TOO.BIG
sec
rts
.8 clc
rts
*---------------------------------------
EXP.OP.MUL
*---------------------------------------
EXP.OP.DIV
clc
rts
*---------------------------------------
EXP.SetAccA sta SRC.ACC
stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
lda #1
sta SRC.ACC.SIZE
clc
rts
*---------------------------------------
MAN
SAVE /A2OSX.BUILD/BIN/DEV/ASM.S.EXP
LOAD /A2OSX.BUILD/BIN/DEV/ASM.S
ASM