A2osX/BIN/ASM.S.MAC.txt

584 lines
8.4 KiB
Plaintext
Raw Normal View History

2018-01-29 07:41:05 +00:00
NEW
2019-09-02 06:09:28 +00:00
AUTO 3,1
2018-01-29 07:41:05 +00:00
*---------------------------------------
MAC.Init >SYSCALL SListNew
bcs .9
2018-01-29 07:41:05 +00:00
2019-03-29 16:21:30 +00:00
>STA.G MAC.hList
2020-02-23 20:01:48 +00:00
>LDYAI 256
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
bcs .9
2020-02-23 20:01:48 +00:00
txa
2019-03-29 16:21:30 +00:00
>STA.G MAC.hBuf
>LDYAI 256
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
bcs .9
2020-02-23 20:01:48 +00:00
>STYA ZPMacroArgBuf
txa
>STA.G MAC.hArgBuf
2020-02-25 16:42:22 +00:00
>LDYAI MA.MAXDEPTH*6
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
2020-02-23 20:01:48 +00:00
bcs .9
2019-03-29 16:21:30 +00:00
>STYA ZPMacroStk
txa
2019-03-29 16:21:30 +00:00
>STA.G MAC.hStk
2020-02-25 16:42:22 +00:00
2019-10-03 06:25:27 +00:00
.9 rts
2018-01-29 07:41:05 +00:00
*---------------------------------------
2020-02-25 16:42:22 +00:00
MAC.Quit >LDA.G MAC.StkPtr
beq .10
jsr MAC.Pop
bra MAC.Quit
.10 >LDA.G MAC.hStk
beq .1
2018-01-29 16:48:07 +00:00
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2020-02-23 20:01:48 +00:00
2019-03-29 16:21:30 +00:00
.1 >LDA.G MAC.hBuf
2020-02-23 20:01:48 +00:00
beq .2
>SYSCALL FreeMem
.2 >LDA.G MAC.hArgBuf
beq .3
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2020-02-23 20:01:48 +00:00
2019-03-29 16:21:30 +00:00
.3 >LDA.G MAC.hList
beq .8
2020-02-23 20:01:48 +00:00
>PUSHA
2018-07-24 16:00:24 +00:00
>SYSCALL SListFree
2018-01-29 07:41:05 +00:00
.8 clc
rts
2018-01-29 07:41:05 +00:00
*---------------------------------------
2020-02-23 20:01:48 +00:00
MAC.Learn >LDA.G MAC.hBuf
>SYSCALL GetMemPtr
>STYA ZPMacroBuf
>STZ.G MAC.BufPtr
sta (ZPMacroBuf)
lda (ZPLinePtr)
cmp #C.SPACE No label, scan to DIR/OP if any
bne .1
jsr SRC.GetNextCharNB
bcs .8
lda #C.SPACE Store ONE blank
jsr MAC.AddChar
bcs .90
lda (ZPLinePtr) get back non blank char
bra .2
.1 jsr MAC.AddChar
bcs .99
jsr SRC.GetNextChar
bcs .80
cmp #C.SPACE
bne .1
jsr MAC.AddChar
.90 bcs .99
jsr SRC.GetNextCharNB
bcs .80
.2 cmp #'.' Directive ?
bne .4
ldy #1
lda (ZPLinePtr),y
beq .3
cmp #'E'
beq .21
cmp #'e'
bne .3
.21 iny
lda (ZPLinePtr),y
beq .3
cmp #'M'
beq .22
cmp #'m'
bne .3
.22 >STZ.G ASM.MA.ON
.8 clc
rts
.80 lda #C.CR
jmp MAC.AddChar
.3 lda (ZPLinePtr)
.4 jsr MAC.AddChar
bcs .99
jsr SRC.GetNextChar
bcs .80
cmp #C.SPACE
bne .4
jsr SRC.GetNextChar
bcs .8
cmp #C.SPACE
beq .80 Comments...
pha
lda #C.SPACE
jsr MAC.AddChar
pla
bcs .99
.5 jsr MAC.AddChar Store ARG....
bcs .99
jsr SRC.GetNextChar
bcs .80
cmp #C.SPACE
bne .5
bra .80 End of Line
.99 rts
*---------------------------------------
2019-03-18 16:48:16 +00:00
MAC.AddChar tax
2020-02-23 20:01:48 +00:00
>LDA.G ASM.PASS If Pass#2, ignore
2019-03-22 16:47:33 +00:00
bne .8
2020-02-23 20:01:48 +00:00
2019-03-18 16:48:16 +00:00
>LDA.G MAC.BufPtr
tay
2019-03-18 16:48:16 +00:00
txa
sta (ZPMacroBuf),y
2019-03-18 16:48:16 +00:00
>INC.G MAC.BufPtr
txa
2019-04-01 06:07:56 +00:00
beq .1
cmp #C.CR
bne .8
2020-02-23 20:01:48 +00:00
.1 >PUSHB.G MAC.hList
>PUSHW.G MAC.ID
>PUSHW ZPMacroBuf
>LDA.G MAC.BufPtr
2019-03-18 16:48:16 +00:00
tay
lda #0
>PUSHYA
>SYSCALL SListAddData
rts
2020-02-23 20:01:48 +00:00
.8 clc
2019-04-01 06:07:56 +00:00
rts
*---------------------------------------
MAC.Exec jsr SRC.GetNextChar skip '>'
bcs .90
2020-02-23 20:01:48 +00:00
>PUSHB.G MAC.hList
2019-04-01 06:07:56 +00:00
>PUSHW ZPLinePtr
>SYSCALL SListLookup
bcs .90
2020-02-23 20:01:48 +00:00
2019-04-01 06:07:56 +00:00
>STYA ZPPtr1 MAC.ID
txa
* clc
adc ZPLinePtr
sta ZPLinePtr
bcc .1
inc ZPLinePtr+1
2020-02-23 20:01:48 +00:00
2019-04-01 06:07:56 +00:00
.1 jsr SRC.GetChar
bcs .8
2020-02-23 20:01:48 +00:00
cmp #C.SPACE
2019-04-01 06:07:56 +00:00
bne .92
2020-02-23 20:01:48 +00:00
2019-04-01 06:07:56 +00:00
jsr SRC.GetNextChar
beq .8 eol..
2020-02-23 20:01:48 +00:00
cmp #C.SPACE some arg...
2019-04-01 06:07:56 +00:00
bne .8
2020-02-23 20:01:48 +00:00
2019-04-01 06:07:56 +00:00
.2 jsr SRC.GetNextChar comment....skip
bcc .2
2020-02-23 20:01:48 +00:00
.8 jmp MAC.Push
.90 lda #E.MACRO.INV
sec
rts
.92 lda #E.SYNTAX.ERROR
sec
MAC.Exec.RTS rts
*---------------------------------------
MAC.ReadLine >LDA.G MAC.hBuf
>SYSCALL GetMemPtr
>STYA ZPMacroBuf
jsr MAC.Get ZPMacroArgBuf = args
>PUSHB.G MAC.hList
>PUSHW ZPPtr1 Mac ID
>PUSHW ZPMacroBuf
>PUSHWZ len = 0 (string mode)
>PUSHW ZPPtr2 offset
>SYSCALL SListGetData
bcs MAC.Exec.RTS
pha
tya
sec +1 for CR
adc ZPPtr2
sta ZPPtr2
pla
adc ZPPtr2+1
sta ZPPtr2+1
ldy #0
2020-03-09 06:58:48 +00:00
stz DIR.Byte
2020-02-23 20:01:48 +00:00
.1 lda (ZPMacroBuf)
2020-02-25 16:42:22 +00:00
beq .8
cmp #C.CR
beq .8
2020-02-23 20:01:48 +00:00
inc ZPMacroBuf
bne .2
inc ZPMacroBuf+1
2020-03-09 16:24:08 +00:00
.2 cmp #']'
2020-02-23 20:01:48 +00:00
bne .7
2020-03-09 06:58:48 +00:00
bit DIR.Byte
bmi .7
2020-02-23 20:01:48 +00:00
lda (ZPMacroBuf)
beq .9
2020-02-24 13:33:28 +00:00
2020-02-23 20:01:48 +00:00
inc ZPMacroBuf
bne .21
inc ZPMacroBuf+1
.21 cmp #'#'
2020-03-02 16:49:47 +00:00
bne .22
2020-02-25 16:42:22 +00:00
2020-02-24 16:37:55 +00:00
lda ZPMacroArgCnt
2020-02-23 20:01:48 +00:00
ora #$30
2020-03-09 06:58:48 +00:00
bra .7
2020-02-23 20:01:48 +00:00
2020-03-02 16:49:47 +00:00
.22 cmp #'1'
2020-03-09 06:58:48 +00:00
bcc .6
2020-02-23 20:01:48 +00:00
cmp #'9'+1
2020-03-09 06:58:48 +00:00
bcs .6
2020-02-25 16:42:22 +00:00
2020-02-23 20:01:48 +00:00
and #$0f
tax
2020-02-25 16:42:22 +00:00
dec
cmp ZPMacroArgCnt
bcs .1
2020-02-23 20:01:48 +00:00
jsr MAC.GetArgX
2020-02-25 16:42:22 +00:00
bcs .1 no arg ]n, append nothing
2020-02-23 20:01:48 +00:00
.3 lda (ZPPtr1)
sta (ZPLineBuf),y
iny
inc ZPPtr1
bne .4
inc ZPPtr1+1
.4 dex
bne .3
bra .1
2020-03-09 06:58:48 +00:00
.6 pha
lda #']'
sta (ZPLineBuf),y
iny
pla
2020-02-23 20:01:48 +00:00
.7 sta (ZPLineBuf),y
iny
bra .1
2020-02-25 16:42:22 +00:00
.8 lda #0
sta (ZPLineBuf),y
jmp MAC.Put
2020-02-23 20:01:48 +00:00
.9 lda #E.SYNTAX.ERROR
sec
2020-03-03 16:44:52 +00:00
MAC.ReadLine.RTS
2020-02-23 20:01:48 +00:00
rts
*---------------------------------------
MAC.Push >LDA.G MAC.StkPtr
2020-02-25 16:42:22 +00:00
cmp #MA.MAXDEPTH*6
2020-03-03 16:44:52 +00:00
beq MAC.ReadLine.RTS
2020-02-23 20:01:48 +00:00
2020-02-24 16:37:55 +00:00
>LDA.G MAC.CtxID
pha
2020-02-25 16:42:22 +00:00
>INC.G MAC.CtxStackPtr
2020-02-24 16:37:55 +00:00
clc
2020-02-25 16:42:22 +00:00
adc #MAC.CtxStack-1
2020-02-24 16:37:55 +00:00
tay
pla
sta (pData),y
2020-02-23 20:01:48 +00:00
2020-02-25 16:42:22 +00:00
>INC.G MAC.CtxNextID
2020-02-24 16:37:55 +00:00
>STA.G MAC.CtxID
2020-03-09 16:24:08 +00:00
ldy #$ff
.10 iny
lda (ZPLinePtr),y
bne .10
iny
iny
lda #0
>SYSCALL GetMem
bcs MAC.ReadLine.RTS
2020-02-24 16:37:55 +00:00
>STYA ZPPtr2
2020-03-09 16:24:08 +00:00
phx hArgs
2020-02-25 16:42:22 +00:00
2020-03-09 16:24:08 +00:00
ldx #0 arg cnt
2020-02-24 16:37:55 +00:00
.1 ldy #$ff
2020-03-03 16:44:52 +00:00
stz DIR.Byte between " flag
2020-02-24 16:37:55 +00:00
.2 iny
2020-03-09 16:24:08 +00:00
lda (ZPLinePtr),y
2020-02-24 16:37:55 +00:00
beq .3
2020-03-09 16:24:08 +00:00
cmp #C.SPACE end of args ?
2020-03-03 16:44:52 +00:00
bne .21
2020-03-09 16:24:08 +00:00
2020-03-03 16:44:52 +00:00
bit DIR.Byte
2020-03-09 16:24:08 +00:00
beq .3
2020-03-03 16:44:52 +00:00
2020-03-09 16:24:08 +00:00
.20 sta (ZPPtr2)
inc ZPPtr2
bne .2
inc ZPPtr2+1
bra .2
2020-03-03 16:44:52 +00:00
.21 cmp #'"'
bne .22
lda DIR.Byte
eor #$ff
sta DIR.Byte
bra .2
.22 cmp #','
2020-03-09 16:24:08 +00:00
bne .20
bit DIR.Byte
bmi .20
2020-02-24 16:37:55 +00:00
lda #0
2020-03-09 16:24:08 +00:00
sta (ZPPtr2)
2020-02-24 16:37:55 +00:00
2020-03-09 16:24:08 +00:00
inc ZPPtr2
bne .23
inc ZPPtr2+1
.23 tya
2020-02-24 16:37:55 +00:00
beq .4
2020-02-23 20:01:48 +00:00
2020-02-24 16:37:55 +00:00
inx
sec
2020-03-09 16:24:08 +00:00
adc ZPLinePtr
sta ZPLinePtr
2020-02-24 16:37:55 +00:00
bcc .1
2020-03-09 16:24:08 +00:00
inc ZPLinePtr+1
2020-02-24 16:37:55 +00:00
bra .1
2020-02-25 16:42:22 +00:00
2020-03-09 16:24:08 +00:00
.3 lda #0
sta (ZPPtr2)
tya
2020-02-25 16:42:22 +00:00
beq .4
inx
2020-02-24 16:37:55 +00:00
.4 >LDA.G MAC.StkPtr
2019-04-01 06:07:56 +00:00
tay
2020-02-24 16:37:55 +00:00
pla push hArgs
2020-02-23 20:01:48 +00:00
sta (ZPMacroStk),y
iny
2020-02-24 16:37:55 +00:00
txa push arg count
sta (ZPMacroStk),y
iny
lda #0 push offset
2020-02-23 20:01:48 +00:00
sta (ZPMacroStk),y
iny
2019-04-01 06:07:56 +00:00
sta (ZPMacroStk),y
2020-02-23 20:01:48 +00:00
2019-04-01 06:07:56 +00:00
iny
2020-02-23 20:01:48 +00:00
lda ZPPtr1+1 push MAC.ID
2019-04-01 06:07:56 +00:00
sta (ZPMacroStk),y
iny
2020-02-23 20:01:48 +00:00
lda ZPPtr1
sta (ZPMacroStk),y
iny
tya
>STA.G MAC.StkPtr
clc
rts
2019-04-01 06:07:56 +00:00
2020-02-23 20:01:48 +00:00
.9 lda #E.MACRO.TOO.MANY
2019-04-01 06:07:56 +00:00
sec
2020-03-09 16:24:08 +00:00
rts
2020-02-23 20:01:48 +00:00
*---------------------------------------
MAC.Pop >LDA.G MAC.StkPtr
dec
2020-02-25 16:42:22 +00:00
dec mac id
2020-02-23 20:01:48 +00:00
dec
2020-02-25 16:42:22 +00:00
dec offset
2020-02-23 20:01:48 +00:00
2020-02-25 16:42:22 +00:00
dec arg cnt
dec hArgs
2020-02-23 20:01:48 +00:00
2020-02-24 16:37:55 +00:00
sta (pData),y 6 bytes off stack
2020-02-23 20:01:48 +00:00
tay
lda (ZPMacroStk),y
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2020-02-23 20:01:48 +00:00
2020-02-25 16:42:22 +00:00
>LDA.G MAC.CtxStackPtr
2020-02-24 16:37:55 +00:00
clc
2020-02-25 16:42:22 +00:00
adc #MAC.CtxStack-1
2020-02-24 16:37:55 +00:00
tay
lda (pData),y
>STA.G MAC.CtxID
2020-02-25 16:42:22 +00:00
>DEC.G MAC.CtxStackPtr
2020-02-24 16:37:55 +00:00
2020-02-23 20:01:48 +00:00
clc
2019-03-18 16:48:16 +00:00
rts
2020-02-23 20:01:48 +00:00
*---------------------------------------
MAC.Get >LDA.G MAC.StkPtr
tay
dey
lda (ZPMacroStk),y
sta ZPPtr1
dey
lda (ZPMacroStk),y
sta ZPPtr1+1 get mac ID
dey
lda (ZPMacroStk),y
sta ZPPtr2
dey
lda (ZPMacroStk),y
sta ZPPtr2+1 get offset
2020-02-24 16:37:55 +00:00
dey
lda (ZPMacroStk),y get arg count
sta ZPMacroArgCnt
2020-02-23 20:01:48 +00:00
dey
lda (ZPMacroStk),y
>SYSCALL GetMemPtr
>STYA ZPMacroArgBuf get args
rts
*---------------------------------------
2020-02-25 16:42:22 +00:00
MAC.Put >LDA.G MAC.StkPtr
tay
dey to arg cnt
dey
dey skip mac ID
lda ZPPtr2
sta (ZPMacroStk),y
dey
lda ZPPtr2+1
sta (ZPMacroStk),y save offset
clc
rts
*---------------------------------------
2020-02-23 20:01:48 +00:00
MAC.GetArgX phy
>LDYA ZPMacroArgBuf
>STYA ZPPtr1
2020-02-25 16:42:22 +00:00
2020-02-24 16:37:55 +00:00
.1 ldy #$ff
2020-02-23 20:01:48 +00:00
2020-02-24 16:37:55 +00:00
.2 iny
2020-02-23 20:01:48 +00:00
lda (ZPPtr1),y
2020-02-24 16:37:55 +00:00
bne .2
2020-02-23 20:01:48 +00:00
2020-02-24 16:37:55 +00:00
.3 dex
beq .4
2020-02-23 20:01:48 +00:00
tya
beq .9
2020-02-25 16:42:22 +00:00
sec
2020-02-23 20:01:48 +00:00
adc ZPPtr1
2020-02-24 16:37:55 +00:00
sta ZPPtr1
bcc .1
2020-02-23 20:01:48 +00:00
inc ZPPtr1+1
2020-02-24 16:37:55 +00:00
bra .1
2020-02-23 20:01:48 +00:00
2020-02-24 16:37:55 +00:00
.4 tya
2020-02-23 20:01:48 +00:00
tax
beq .9
ply
clc
rts
.9 ply
2019-04-01 06:07:56 +00:00
sec
2020-02-23 20:01:48 +00:00
rts
*---------------------------------------
2018-01-29 07:41:05 +00:00
MAN
2019-01-28 07:44:37 +00:00
SAVE USR/SRC/BIN/ASM.S.MAC
LOAD USR/SRC/BIN/ASM.S
2018-01-29 07:41:05 +00:00
ASM