A2osX/BIN/ASM.S.EXP.txt
2017-03-29 17:48:15 +02:00

280 lines
5.2 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.

PR#3
PREFIX /A2OSX.BUILD
NEW
INC 1
AUTO 6
.LIST OFF
*---------------------------------------
* U-Operators :
* B-Operators :
* Num Format : 0-9 -> decimal
* $ = Hex
* % = binary
* & = octal
* * = PC
*---------------------------------------
EXP.Eval stz EXP.Operator
stz EXP.Modifier
jsr SRC.GetCharNB
beq EXP.Eval.Missing
jsr SRC.IsMODReserved
bcs EXP.Eval.Next1
stx EXP.Modifier
bra EXP.Eval.Next
EXP.Eval.Missing lda #ERR.MISSING.EXP
sec
rts
EXP.Eval.Next jsr SRC.GetCharUC
beq EXP.Eval.Missing
EXP.Eval.Next1 cmp #'.' Local Label?
bne .12
jsr EXP.GetLocal
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
jmp EXP.EvalOperator
.10 jsr SRC.IsDigit10 Decimal constant ?
bcs .1
dec SRC.BufPtr
jsr SRC.GetDecimal
bcs EXP.EvalExitSYN
bra EXP.EvalOperator
.1 cmp #'$' Hex?
bne .2
jsr SRC.GetHex
bcs EXP.EvalExitSYN
bra EXP.EvalOperator
.2 cmp #'%' binary?
bne .3
jsr SRC.GetBinary
bcs EXP.EvalExitSYN
bra EXP.EvalOperator
.3 cmp #'&' octal?
bne .4
jsr SRC.GetOctal
bcs EXP.EvalExitSYN
bra EXP.EvalOperator
.4 cmp #'''
bne .43
jsr SRC.GetChar
beq EXP.EvalExitSYN
jsr EXP.SetAccA
jsr SRC.GetChar
beq EXP.EvalOperator
cmp #'''
bne EXP.EvalExitSYN
bra EXP.EvalOperator
.43 cmp '"'
bne .42
jsr SRC.GetChar
beq EXP.EvalExitSYN
ora #$80
jsr EXP.SetAccA
jsr SRC.GetChar
beq EXP.EvalOperator
cmp #'"'
bne EXP.EvalExitSYN
bra EXP.EvalOperator
.42 jsr SRC.IsLetter Symbol ?
bcs EXP.EvalExitSYN
dec SRC.BufPtr
jsr EXP.GetSymbol
bcs EXP.EvalExitRTS
bra EXP.EvalOperator
EXP.EvalExitOK dec SRC.BufPtr Back One Char
EXP.EvalExitOK1 clc
EXP.EvalExitRTS rts
EXP.EvalExitSYN lda #ERR.SYNTAX.ERROR
sec
rts
EXP.EvalExitUND lda #ERR.UNDEF.SYMBOL
sec
rts
EXP.EvalOperator lda EXP.Operator
beq .7
jsr EXP.Compute
bcs EXP.EvalExitRTS
.7 jsr SRC.GetChar
beq EXP.EvalExitOK1
cmp #' '
beq EXP.EvalExitOK
jsr SRC.IsAMReserved
bcc EXP.EvalExitOK
jsr SRC.IsEXPReserved
bcs EXP.EvalExitSYN
stx EXP.Operator
ldx #3
.8 lda SRC.ACC,x
sta SRC.ARG,x
dex
bpl .8
jmp EXP.Eval.Next
*---------------------------------------
EXP.GetLocal 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.SearchLocal
bcs EXP.EvalExitUND
rts
*---------------------------------------
EXP.SetAccA sta SRC.ACC
stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
rts
*---------------------------------------
EXP.GetSymbol >LDYA L.SRC.ELabel.Len
jsr SRC.GetLabel
bcs EXP.EvalExitSYN
>LDYA L.SRC.ELabel.Flags
jsr SYM.SearchGlobal
bcc .1
ldy #ASM.PASS
lda (pData),y pass#2?
bne EXP.EvalExitUND yes, undefined symbol
lda #$C0 Valid+Pending
sta SRC.ELabel.Flags
>LDYA L.SRC.ELabel.Flags
jsr SYM.AddGToGBlockYA
rts
.1 ldx #3
.2 lda SRC.FLabel.Value,x
sta SRC.ACC,x
dex
bpl .2
clc
rts
*---------------------------------------
EXP.Compute dec
asl
tax
* ldy #ASM.PASS
* lda (pData),y pass#2?
* beq .8
jmp (J.EXP.OP,x)
.8 clc
rts
*---------------------------------------
EXP.OP.EOR
*---------------------------------------
EXP.OP.ORA
*---------------------------------------
EXP.OP.AND
*---------------------------------------
EXP.OP.LOW
*---------------------------------------
EXP.OP.EQU
*---------------------------------------
EXP.OP.GRT
clc
rts
*---------------------------------------
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
*---------------------------------------
MAN
SAVE /A2OSX.SRC/BIN/ASM.S.EXP
LOAD BIN/ASM.S
ASM