mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-25 05:32:20 +00:00
455 lines
7.2 KiB
Plaintext
455 lines
7.2 KiB
Plaintext
NEW
|
||
AUTO 3,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 #E.MISSING.EXP
|
||
sec
|
||
rts
|
||
|
||
EXP.Eval >STZ.G EXP.Modifier
|
||
>STA.G EXP.Prefix
|
||
>STA.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 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
|
||
|
||
>LDA.G MAC.StkPtr
|
||
bne .9 illegal INSIDE macro
|
||
|
||
bra .13
|
||
|
||
.12 cmp #':'
|
||
bne .14
|
||
|
||
>LDA.G MAC.StkPtr
|
||
beq .9 illegal OUTSIDE macro
|
||
|
||
.13 jsr EXP.GetLocal
|
||
bcs .99
|
||
|
||
jmp EXP.EvalOperator
|
||
|
||
.14 cmp #'*'
|
||
bne .10
|
||
|
||
jsr SYM.PC2Acc
|
||
|
||
jsr SRC.GetNextChar
|
||
jmp EXP.EvalOperator
|
||
|
||
.9 lda #E.INV.LABEL
|
||
sec
|
||
.99 rts
|
||
*---------------------------------------
|
||
.10 jsr SRC.IsDigit10 Decimal constant ?
|
||
bcs .1
|
||
|
||
jsr SRC.GetDecimal
|
||
bcs EXP.EvalExitRTS
|
||
jmp EXP.EvalOperator
|
||
|
||
.1 cmp #'$' Hex?
|
||
bne .2
|
||
|
||
jsr SRC.GetHex
|
||
bcs EXP.EvalExitRTS
|
||
jmp EXP.EvalOperator
|
||
|
||
.2 cmp #'%' binary?
|
||
bne .3
|
||
|
||
jsr SRC.GetBinary
|
||
bcs EXP.EvalExitRTS
|
||
jmp 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 #'''
|
||
beq .44
|
||
|
||
cmp #','
|
||
bne EXP.EvalExitSYN
|
||
|
||
bra EXP.EvalOperator
|
||
|
||
.44 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 #'"'
|
||
beq .45
|
||
|
||
cmp #','
|
||
bne EXP.EvalExitSYN
|
||
bra EXP.EvalOperator
|
||
|
||
.45 jsr SRC.GetNextChar
|
||
bra EXP.EvalOperator
|
||
|
||
.42 jsr SRC.IsLetter Symbol ?
|
||
bcs EXP.EvalExitSYN
|
||
|
||
jsr SYM.LookupGlobal
|
||
bcc EXP.EvalOperator
|
||
EXP.EvalExitRTS rts
|
||
|
||
EXP.EvalExitOK >LDA.G EXP.Modifier
|
||
beq .1
|
||
|
||
asl
|
||
tax
|
||
|
||
lda #SYMG.F.FWREF Reset FW flag because of IMM modifier
|
||
trb SRC.ACC.F
|
||
|
||
jmp (J.EXP.MOD-2,x)
|
||
|
||
.1 clc
|
||
rts
|
||
|
||
EXP.EvalExitSYN lda #E.SYNTAX.ERROR
|
||
sec
|
||
rts
|
||
|
||
EXP.EvalExitUND lda #E.UNDEF.SYMBOL
|
||
sec
|
||
rts
|
||
*---------------------------------------
|
||
EXP.EvalOperator
|
||
>LDA.G EXP.Operator
|
||
beq .7 no previous OP....
|
||
|
||
asl
|
||
tax
|
||
|
||
lda SRC.ACC.F
|
||
ora SRC.ARG.F
|
||
and #SYMG.F.FWREF
|
||
tsb SRC.ACC.F
|
||
|
||
jsr EXP.Compute ARG op ACC -> ACC
|
||
bcc .7
|
||
|
||
tax
|
||
>LDA.G ASM.PASS
|
||
beq .7 Ignore error ...
|
||
|
||
txa
|
||
rts
|
||
|
||
.7 jsr SRC.GetChar
|
||
bcs EXP.EvalExitOK
|
||
|
||
cmp #C.SPACE
|
||
beq EXP.EvalExitOK
|
||
|
||
jsr SRC.IsAMReserved
|
||
bcc EXP.EvalExitOK
|
||
|
||
jsr SRC.IsEXPReserved
|
||
bcs EXP.EvalExitSYN
|
||
|
||
txa
|
||
>STA.G EXP.Operator
|
||
|
||
ldx #3
|
||
|
||
.8 lda SRC.ACC,x
|
||
sta SRC.ARG,x
|
||
dex
|
||
bpl .8
|
||
|
||
lda SRC.ACC.F
|
||
sta SRC.ARG.F
|
||
|
||
jmp EXP.Eval.Next0
|
||
*---------------------------------------
|
||
EXP.GetLocal jsr SRC.GetNextChar
|
||
bcs .9
|
||
|
||
jsr SRC.GetDecimal8
|
||
bcs EXP.EvalExitSYN
|
||
|
||
tax
|
||
|
||
jsr SYM.LookupLocalX
|
||
bcc .8
|
||
|
||
>LDA.G ASM.PASS pass#2?
|
||
bne EXP.EvalExitUND
|
||
|
||
lda #SYMG.F.FWREF
|
||
tsb SRC.ACC.F
|
||
|
||
lda #2
|
||
sta SRC.ACC.SIZE
|
||
|
||
lda #$ff
|
||
sta SRC.ACC
|
||
sta SRC.ACC+1
|
||
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.SYNTAX.ERROR
|
||
sec
|
||
|
||
.8 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 jmp (J.EXP.OP-2,x)
|
||
*---------------------------------------
|
||
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.EQU ldx #0 ARG-ACC->ACC
|
||
ldy #4
|
||
|
||
clc if 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
|
||
jmp EXP.SetAccA
|
||
*---------------------------------------
|
||
EXP.OP.LWR jsr EXP.SUB
|
||
bcc .2
|
||
|
||
ldx #3
|
||
|
||
.1 lda SRC.ACC,x
|
||
bne .2
|
||
|
||
dex
|
||
bpl .1
|
||
|
||
clc
|
||
|
||
.2 lda #0
|
||
rol
|
||
jmp EXP.SetAccA
|
||
*---------------------------------------
|
||
EXP.OP.GRT jsr EXP.SUB
|
||
bcc .2
|
||
|
||
ldx #3
|
||
|
||
.1 lda SRC.ACC,x
|
||
bne .2
|
||
|
||
dex
|
||
bpl .1
|
||
|
||
clc
|
||
|
||
.2 lda #0
|
||
rol
|
||
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 #E.VAL.TOO.BIG
|
||
.8 rts
|
||
*---------------------------------------
|
||
EXP.OP.SUB jsr EXP.SUB
|
||
bcs .8
|
||
|
||
lda #E.VAL.TOO.BIG
|
||
sec
|
||
rts
|
||
|
||
.8 clc
|
||
rts
|
||
*---------------------------------------
|
||
EXP.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
|
||
|
||
rts
|
||
*---------------------------------------
|
||
EXP.OP.MUL >PUSHL SRC.ARG
|
||
>PUSHL SRC.ACC
|
||
>FPU uMUL
|
||
>PULLL SRC.ACC
|
||
clc
|
||
rts
|
||
*---------------------------------------
|
||
EXP.OP.DIV >PUSHL SRC.ARG
|
||
>PUSHL SRC.ACC
|
||
>FPU uDIV
|
||
>PULLL SRC.ACC
|
||
clc
|
||
rts
|
||
*---------------------------------------
|
||
EXP.ResetAcc stz SRC.ACC.F
|
||
|
||
EXP.ResetAccV lda #2
|
||
sta SRC.ACC.SIZE
|
||
|
||
stz SRC.ACC
|
||
stz SRC.ACC+1
|
||
stz SRC.ACC+2
|
||
stz SRC.ACC+3
|
||
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
|
||
*---------------------------------------
|
||
.DO ASMDBG=1
|
||
EXP.DBG >SYSCALL putchar
|
||
>PUSHW L.MSG.DBG
|
||
>PUSHB.G MAC.CtxID
|
||
>PUSHL SRC.ARG
|
||
>PUSHL SRC.ACC
|
||
>PUSHB SRC.ACC.F
|
||
>PUSHB SRC.ACC.SIZE
|
||
>PUSHBI 11
|
||
>SYSCALL PrintF
|
||
* >DEBUG
|
||
rts
|
||
.FIN
|
||
*---------------------------------------
|
||
MAN
|
||
SAVE usr/src/bin/asm.s.exp
|
||
LOAD usr/src/bin/asm.s
|
||
ASM
|