A2osX/BIN/ASM.S.EXP.txt

440 lines
7.0 KiB
Plaintext
Raw Normal View History

NEW
2019-09-02 06:09:28 +00:00
AUTO 3,1
2015-10-09 15:53:30 +00:00
*---------------------------------------
* EXP.Modifiers:
2020-08-17 13:03:39 +00:00
* # : 8b,Byte 1
* / : 8b,Byte 2
* ^ : 8b,Byte 3
* < : 24b,Byte 1,2,3
* > : 32b
*---------------------------------------
2015-10-09 15:53:30 +00:00
* Num Format : 0-9 -> decimal
2015-10-28 16:55:12 +00:00
* $ = Hex
2015-10-09 15:53:30 +00:00
* % = binary
* & = octal
2015-10-28 16:55:12 +00:00
* * = PC
2015-10-09 15:53:30 +00:00
*---------------------------------------
EXP.Eval.Missing
2019-03-25 07:04:40 +00:00
lda #E.MISSING.EXP
sec
2019-10-03 06:25:27 +00:00
rts
2020-08-17 13:03:39 +00:00
EXP.Eval >STZ.G EXP.Modifier
2020-03-09 06:58:48 +00:00
>STA.G EXP.Prefix
>STA.G EXP.Operator
2020-03-02 16:49:47 +00:00
jsr SRC.GetChar
bcs EXP.Eval.Missing
2020-03-06 06:56:36 +00:00
jsr SRC.IsMODReserved
bcs EXP.Eval.Next
2020-03-02 16:49:47 +00:00
txa
>STA.G EXP.Modifier
2020-03-02 16:49:47 +00:00
lda #'#'
>STA.G EXP.Prefix
2020-03-02 16:49:47 +00:00
EXP.Eval.Next0 jsr SRC.GetNextChar
2020-03-02 16:49:47 +00:00
2020-03-06 16:20:29 +00:00
EXP.Eval.Next stz SRC.ACC
stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
2020-03-03 16:44:52 +00:00
jsr SRC.GetChar
bcs EXP.Eval.Missing
2020-02-25 16:42:22 +00:00
cmp #'.' Local Label?
2019-04-01 06:07:56 +00:00
bne .12
2020-02-25 16:42:22 +00:00
>LDA.G MAC.StkPtr
2020-08-17 13:03:39 +00:00
bne .9 illegal INSIDE macro
2020-02-25 16:42:22 +00:00
bra .13
2020-08-17 13:03:39 +00:00
2020-02-25 16:42:22 +00:00
.12 cmp #':'
bne .14
2020-08-17 13:03:39 +00:00
2020-02-25 16:42:22 +00:00
>LDA.G MAC.StkPtr
beq .9 illegal OUTSIDE macro
2020-03-02 06:53:19 +00:00
2020-02-29 14:06:28 +00:00
.13 jsr EXP.GetLocal
2020-03-02 16:49:47 +00:00
bcs .99
2020-03-02 06:53:19 +00:00
jmp EXP.EvalOperator
2020-08-17 13:03:39 +00:00
2020-02-25 16:42:22 +00:00
.14 cmp #'*'
bne .10
2020-08-17 13:03:39 +00:00
2020-03-02 06:53:19 +00:00
jsr SYM.PC2Acc
2020-08-17 13:03:39 +00:00
jsr SRC.GetNextChar
jmp EXP.EvalOperator
2020-08-17 13:03:39 +00:00
2020-02-25 16:42:22 +00:00
.9 lda #E.INV.LABEL
sec
2020-03-02 16:49:47 +00:00
.99 rts
2020-02-25 16:42:22 +00:00
*---------------------------------------
.10 jsr SRC.IsDigit10 Decimal constant ?
bcs .1
2020-02-25 16:42:22 +00:00
jsr SRC.GetDecimal
bcs EXP.EvalExitRTS
2019-03-29 16:21:30 +00:00
jmp EXP.EvalOperator
2020-08-17 13:03:39 +00:00
.1 cmp #'$' Hex?
bne .2
2020-02-25 16:42:22 +00:00
jsr SRC.GetHex
bcs EXP.EvalExitRTS
2020-03-06 16:20:29 +00:00
jmp EXP.EvalOperator
2020-08-17 13:03:39 +00:00
.2 cmp #'%' binary?
bne .3
jsr SRC.GetBinary
bcs EXP.EvalExitRTS
2020-03-06 16:20:29 +00:00
jmp EXP.EvalOperator
2020-02-25 16:42:22 +00:00
.3 cmp #'&' octal?
bne .4
2020-08-17 13:03:39 +00:00
jsr SRC.GetOctal
bcs EXP.EvalExitRTS
2019-10-03 06:25:27 +00:00
bra EXP.EvalOperator
.4 cmp #'''
bne .43
2020-08-17 13:03:39 +00:00
jsr SRC.GetNextChar
bcs EXP.EvalExitSYN
jsr EXP.SetAccA
jsr SRC.GetNextChar
bcs EXP.EvalOperator
2020-08-17 13:03:39 +00:00
cmp #'''
2019-03-29 16:21:30 +00:00
beq .44
2020-08-17 13:03:39 +00:00
2019-03-29 16:21:30 +00:00
cmp #','
bne EXP.EvalExitSYN
2020-08-17 13:03:39 +00:00
2019-03-29 16:21:30 +00:00
bra EXP.EvalOperator
2020-08-17 13:03:39 +00:00
2019-03-29 16:21:30 +00:00
.44 jsr SRC.GetNextChar
2020-02-25 16:42:22 +00:00
bra EXP.EvalOperator
.43 cmp #'"'
bne .42
2020-02-25 16:42:22 +00:00
jsr SRC.GetNextChar
bcs EXP.EvalExitSYN
2020-08-17 13:03:39 +00:00
ora #$80
jsr EXP.SetAccA
jsr SRC.GetNextChar
bcs EXP.EvalOperator
2020-08-17 13:03:39 +00:00
cmp #'"'
2019-03-29 16:21:30 +00:00
beq .45
2020-03-06 06:56:36 +00:00
2019-03-29 16:21:30 +00:00
cmp #','
bne EXP.EvalExitSYN
2019-03-29 16:21:30 +00:00
bra EXP.EvalOperator
2020-08-17 13:03:39 +00:00
2019-03-29 16:21:30 +00:00
.45 jsr SRC.GetNextChar
2020-02-27 16:46:40 +00:00
bra EXP.EvalOperator
.42 jsr SRC.IsLetter Symbol ?
bcs EXP.EvalExitSYN
2018-01-11 16:34:09 +00:00
2020-03-02 06:53:19 +00:00
jsr SYM.LookupGlobal
2020-08-17 13:03:39 +00:00
.DO ASMDBG=1
lda #"?"
jsr EXP.DBG
.FIN
2020-03-02 06:53:19 +00:00
bcc EXP.EvalOperator
2020-03-06 16:20:29 +00:00
EXP.EvalExitRTS rts
2020-08-17 13:03:39 +00:00
EXP.EvalExitOK >LDA.G EXP.Modifier
2020-03-06 16:20:29 +00:00
beq .1
2020-03-06 06:56:36 +00:00
asl
tax
2020-08-17 13:03:39 +00:00
2020-03-06 16:20:29 +00:00
lda #SYMG.F.FWREF
trb SRC.ACC.F
2020-08-17 13:03:39 +00:00
jmp (J.EXP.MOD-2,x)
2020-08-17 13:03:39 +00:00
2020-03-06 16:20:29 +00:00
.1 clc
rts
2020-02-27 16:46:40 +00:00
2019-03-25 07:04:40 +00:00
EXP.EvalExitSYN lda #E.SYNTAX.ERROR
sec
rts
2015-11-27 16:26:11 +00:00
2019-03-25 07:04:40 +00:00
EXP.EvalExitUND lda #E.UNDEF.SYMBOL
sec
2019-10-03 06:25:27 +00:00
rts
*---------------------------------------
EXP.EvalOperator
>LDA.G EXP.Operator
2020-08-17 13:03:39 +00:00
beq .7 no previous OP....
asl
tax
lda SRC.ACC.F
ora SRC.ARG.F
and #SYMG.F.FWREF
tsb SRC.ACC.F
2020-03-02 06:53:19 +00:00
2020-08-17 13:03:39 +00:00
jsr EXP.Compute ARG op ACC -> ACC
2020-03-02 16:49:47 +00:00
bcc .7
tax
>LDA.G ASM.PASS
beq .7 Ignore error ...
2020-08-17 13:03:39 +00:00
2020-03-02 16:49:47 +00:00
txa
2020-08-17 13:03:39 +00:00
rts
.7 jsr SRC.GetChar
bcs EXP.EvalExitOK
2015-12-04 16:33:33 +00:00
2020-02-28 16:30:16 +00:00
cmp #C.SPACE
beq EXP.EvalExitOK
2015-12-04 16:33:33 +00:00
jsr SRC.IsAMReserved
bcc EXP.EvalExitOK
2015-12-04 16:33:33 +00:00
jsr SRC.IsEXPReserved
bcs EXP.EvalExitSYN
2020-08-17 13:03:39 +00:00
txa
>STA.G EXP.Operator
2020-08-17 13:03:39 +00:00
ldx #3
.8 lda SRC.ACC,x
sta SRC.ARG,x
dex
bpl .8
2020-03-02 06:53:19 +00:00
2020-08-17 13:03:39 +00:00
lda SRC.ACC.F
sta SRC.ARG.F
.DO ASMDBG=1
lda #'@'
jsr EXP.DBG
.FIN
jmp EXP.Eval.Next0
2015-11-27 16:26:11 +00:00
*---------------------------------------
2019-03-22 16:47:33 +00:00
EXP.GetLocal jsr SRC.GetNextChar
bcs .9
2020-02-23 20:01:48 +00:00
2020-02-28 16:30:16 +00:00
jsr SRC.GetDecimal8
bcs EXP.EvalExitSYN
2019-03-29 07:46:36 +00:00
2020-02-28 16:30:16 +00:00
tax
2020-08-17 13:03:39 +00:00
2020-02-28 16:30:16 +00:00
jsr SYM.LookupLocalX
bcc .8
2020-02-23 20:01:48 +00:00
>LDA.G ASM.PASS pass#2?
bne EXP.EvalExitUND
2020-08-17 13:03:39 +00:00
2020-03-05 16:55:02 +00:00
lda #SYMG.F.FWREF
tsb SRC.ACC.F
2020-08-17 13:03:39 +00:00
2020-03-06 16:20:29 +00:00
lda #2
2020-08-17 13:03:39 +00:00
sta SRC.ACC.SIZE
lda #$ff
sta SRC.ACC
sta SRC.ACC+1
clc
rts
2020-08-17 13:03:39 +00:00
2019-03-25 07:04:40 +00:00
.9 lda #E.SYNTAX.ERROR
sec
2020-08-17 13:03:39 +00:00
2020-03-06 16:20:29 +00:00
.8 rts
2019-10-03 06:25:27 +00:00
*---------------------------------------
EXP.MOD.8.3 lda SRC.ACC+2
bra EXP.MOD.8
2020-08-17 13:03:39 +00:00
EXP.MOD.8.2 lda SRC.ACC+1
2020-03-02 06:53:19 +00:00
2019-10-03 06:25:27 +00:00
EXP.MOD.8 sta SRC.ACC
2020-03-02 06:53:19 +00:00
EXP.MOD.8.1 lda #1
sta SRC.ACC.SIZE
clc
rts
2020-03-02 06:53:19 +00:00
EXP.MOD.24 lda #3
sta SRC.ACC.SIZE
clc
2020-08-17 13:03:39 +00:00
rts
2020-03-02 06:53:19 +00:00
EXP.MOD.32 lda #4
sta SRC.ACC.SIZE
clc
2020-08-17 13:03:39 +00:00
rts
*---------------------------------------
2020-08-17 13:03:39 +00:00
EXP.Compute jmp (J.EXP.OP-2,x)
2015-12-04 16:33:33 +00:00
*---------------------------------------
EXP.OP.EOR ldx #3
2018-02-05 07:09:38 +00:00
.1 lda SRC.ARG,x
eor SRC.ACC,x
sta SRC.ACC,x
dex
bpl .1
rts
2015-12-04 16:33:33 +00:00
*---------------------------------------
EXP.OP.ORA ldx #3
2018-02-05 07:09:38 +00:00
.1 lda SRC.ARG,x
ora SRC.ACC,x
sta SRC.ACC,x
dex
bpl .1
rts
2015-12-04 16:33:33 +00:00
*---------------------------------------
EXP.OP.AND ldx #3
2018-02-05 07:09:38 +00:00
.1 lda SRC.ARG,x
and SRC.ACC,x
sta SRC.ACC,x
dex
bpl .1
rts
2015-12-04 16:33:33 +00:00
*---------------------------------------
EXP.OP.LOW jsr EXP.OP.SUB
lda #0
rol
jmp EXP.SetAccA
2015-12-04 16:33:33 +00:00
*---------------------------------------
EXP.OP.EQU ldx #0 ARG-ACC->ACC
ldy #4
2020-03-06 06:56:36 +00:00
2020-03-10 07:24:08 +00:00
clc if not Equals, return 0
2020-03-06 06:56:36 +00:00
.1 lda SRC.ARG,x
eor SRC.ACC,x
bne .2
2020-03-06 06:56:36 +00:00
inx
dey
bne .1
sec equals, return 1
2020-03-06 06:56:36 +00:00
.2 lda #0
rol
2020-03-06 16:20:29 +00:00
jmp EXP.SetAccA
2015-12-04 16:33:33 +00:00
*---------------------------------------
EXP.OP.GRT jsr EXP.OP.SUB
lda #0
rol
eor #1
jmp EXP.SetAccA
2015-12-04 16:33:33 +00:00
*---------------------------------------
EXP.OP.ADD ldx #0 ARG-ACC->ACC
ldy #4
2020-08-17 13:03:39 +00:00
clc
2020-08-17 13:03:39 +00:00
.1 lda SRC.ARG,x
adc SRC.ACC,x
sta SRC.ACC,x
inx
dey
bne .1
2020-08-17 13:03:39 +00:00
bcc .8
2020-03-02 06:53:19 +00:00
2019-03-25 07:04:40 +00:00
lda #E.VAL.TOO.BIG
.8 rts
2015-12-04 16:33:33 +00:00
*---------------------------------------
2020-03-02 06:53:19 +00:00
EXP.OP.SUB ldx #0 ARG-ACC->ACC
ldy #4
sec
2020-08-17 13:03:39 +00:00
.1 lda SRC.ARG,x
sbc SRC.ACC,x
sta SRC.ACC,x
inx
dey
bne .1
2020-08-17 13:03:39 +00:00
bcs .8
2020-08-17 13:03:39 +00:00
2019-03-25 07:04:40 +00:00
lda #E.VAL.TOO.BIG
sec
rts
2020-08-17 13:03:39 +00:00
.8 clc
rts
2015-12-04 16:33:33 +00:00
*---------------------------------------
2020-03-04 06:39:08 +00:00
EXP.OP.MUL >PUSHL SRC.ARG
>PUSHL SRC.ACC
2021-05-04 17:31:21 +00:00
>FPU uMUL
2020-03-04 06:39:08 +00:00
>PULLL SRC.ACC
2020-02-24 16:37:55 +00:00
clc
2020-02-23 20:46:25 +00:00
rts
2015-12-04 16:33:33 +00:00
*---------------------------------------
2020-03-04 06:39:08 +00:00
EXP.OP.DIV >PUSHL SRC.ARG
>PUSHL SRC.ACC
2021-05-04 17:31:21 +00:00
>FPU uDIV
2020-03-04 06:39:08 +00:00
>PULLL SRC.ACC
2020-02-24 16:37:55 +00:00
clc
rts
2015-11-27 16:26:11 +00:00
*---------------------------------------
2020-03-06 16:20:29 +00:00
EXP.ResetAcc stz SRC.ACC.F
2020-08-17 13:03:39 +00:00
EXP.ResetAccV lda #2
2020-03-06 16:20:29 +00:00
sta SRC.ACC.SIZE
2020-08-17 13:03:39 +00:00
2020-03-06 16:20:29 +00:00
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
2020-08-17 13:03:39 +00:00
*---------------------------------------
.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
*---------------------------------------
2015-10-09 15:53:30 +00:00
MAN
2020-08-17 13:03:39 +00:00
SAVE usr/src/bin/asm.s.exp
LOAD usr/src/bin/asm.s
2015-10-28 16:55:12 +00:00
ASM