A2osX/BIN/ASM.S.SRC.txt

986 lines
17 KiB
Plaintext
Raw Normal View History

NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
2015-10-06 16:14:48 +00:00
*---------------------------------------
2018-01-12 16:05:04 +00:00
SRC.PrintLine bra .8
>LDA.G ASM.MACRO.ON
2015-12-17 16:57:35 +00:00
bpl .1
2018-01-11 16:34:09 +00:00
>LDA.G ASM.LI.CON
2015-12-17 16:57:35 +00:00
bpl .9
bmi .8
2018-01-11 16:34:09 +00:00
.1 >LDA.G ASM.LI.ON
2018-01-12 16:05:04 +00:00
bpl .9
2015-12-17 16:57:35 +00:00
2018-01-11 16:34:09 +00:00
.8 >PUSHW ZPLineBuf
2015-12-17 16:57:35 +00:00
>PUSHW SRC.LINENUM
ldy #ASM.PC+1
>PUSHB (pData),y
dey
>PUSHB (pData),y
>LDYA L.MSG.SRCLINE
>SYSCALL PrintF.YA
2015-12-17 16:57:35 +00:00
.9 rts
*---------------------------------------
2018-01-12 16:05:04 +00:00
SRC.PrintLineErr >PUSHW ZPLineBuf
>LDYA L.MSG.LINECR
2018-01-11 16:34:09 +00:00
>SYSCALL PrintF.YA
bcs .9
2015-12-17 16:57:35 +00:00
2018-01-11 16:34:09 +00:00
lda ZPLinePtr
sec
sbc ZPLineBuf
tax
2015-12-17 16:57:35 +00:00
beq .4
2018-01-11 16:34:09 +00:00
.3 phx
2015-12-17 16:57:35 +00:00
lda #'-'
>SYSCALL PutChar.A
2015-12-17 16:57:35 +00:00
plx
bcs .9
2018-01-11 16:34:09 +00:00
dex
bne .3
2015-12-17 16:57:35 +00:00
.4 lda #'^'
2018-01-11 16:34:09 +00:00
phy
>SYSCALL PutChar.A
2018-01-11 16:34:09 +00:00
ply
2015-12-17 16:57:35 +00:00
bcs .9
.5 lda #13
>SYSCALL PutChar.A
2018-01-11 16:34:09 +00:00
lda #10
>SYSCALL PutChar.A
2015-12-17 16:57:35 +00:00
.9 rts
*---------------------------------------
2018-01-11 16:34:09 +00:00
SRC.ParseLine lda (ZPLineBuf)
tax
2015-12-04 16:33:33 +00:00
beq .1
2015-10-06 16:14:48 +00:00
2018-01-11 16:34:09 +00:00
cmp #'*' Comment?
2015-12-04 16:33:33 +00:00
beq .1
2018-01-11 16:34:09 +00:00
cmp #';' Comment?
2015-12-04 16:33:33 +00:00
beq .1
ldy #ASM.DO.ON
lda (pData),y
bne .1
2015-10-06 16:14:48 +00:00
2015-11-20 16:31:14 +00:00
stz SRC.GLabel.New
2015-10-09 15:53:30 +00:00
cpx #' ' no label...go scan dir/opcode
beq .4
2015-10-06 16:14:48 +00:00
2015-11-20 16:31:14 +00:00
cpx #'.' local symbol?
2015-10-09 15:53:30 +00:00
bne .2
jsr SRC.ParseLine.SymL
bra .3
2015-10-06 16:14:48 +00:00
2015-12-04 16:33:33 +00:00
.1 clc
rts
2015-10-09 15:53:30 +00:00
.2 jsr SRC.ParseLine.SymG
.3 bcs SRC.ParseLine.Err
2018-01-11 16:34:09 +00:00
.4 jsr SRC.GetNextCharNB Scan for an Opcode...
2015-10-06 16:14:48 +00:00
beq SRC.ParseLine.Ok
cmp #'.'
2015-10-09 15:53:30 +00:00
bne .5
2015-10-06 16:14:48 +00:00
2018-01-11 16:34:09 +00:00
jsr SRC.GetNextChar Skip .
2015-10-09 15:53:30 +00:00
jsr SRC.ParseLine.Dir
bcs SRC.ParseLine.Err
2015-10-06 16:14:48 +00:00
bra SRC.ParseLine.Ok
2015-10-28 16:55:12 +00:00
.5 cmp #'>'
bne .6
jsr SRC.ParseLine.Exec.Macro
bcs SRC.ParseLine.Err
bra SRC.ParseLine.Ok
2018-01-11 16:34:09 +00:00
.6 jsr SRC.ParseLine.OpCode
2015-10-09 15:53:30 +00:00
bcs SRC.ParseLine.Err
2015-10-06 16:14:48 +00:00
2015-11-20 16:31:14 +00:00
SRC.ParseLine.Ok lda SRC.GLabel.New
2015-11-27 16:26:11 +00:00
bpl .8
2018-01-12 16:05:04 +00:00
clc
rts
2015-12-17 16:57:35 +00:00
ldy #ASM.PASS
lda (pData),y pass#2?
bne .8 yes, nothing to do
* --- Pass #1
2015-12-04 16:33:33 +00:00
>LDYA L.SRC.GLabel.Flags
jsr SYM.SearchGlobal
2015-11-27 16:26:11 +00:00
bcs .1 if CS, not found, add
lda SRC.FLabel.Flags
2015-12-17 16:57:35 +00:00
bit #$40 found symbol pending ?
bne .2 yes, update
2015-11-27 16:26:11 +00:00
2015-12-17 16:57:35 +00:00
bit #$1 found is .SE ?
beq SRC.ParseLine.Redef no, redefine error
.2 ldx #0 update current symbol with
.3 lda SRC.GLabel.Flags flags & value
jsr SYM.AddByteGBlock
inx
cpx #5
bne .3
bra .8
2015-10-09 15:53:30 +00:00
2015-11-27 16:26:11 +00:00
.1 >LDYA L.SRC.GLabel.Flags
jsr SYM.AddGToGBlockYA
2015-11-20 16:31:14 +00:00
bcs SRC.ParseLine.Err
2015-12-17 16:57:35 +00:00
2015-12-04 16:33:33 +00:00
.8 clc
2015-10-06 16:14:48 +00:00
rts
2015-12-17 16:57:35 +00:00
2018-01-11 16:34:09 +00:00
SRC.ParseLine.Inv lda #ERR.INV.LABEL
2015-10-06 16:14:48 +00:00
SRC.ParseLine.Err sec
rts
2015-12-04 16:33:33 +00:00
2015-11-20 16:31:14 +00:00
SRC.ParseLine.Redef lda #ERR.SYMBOL.REDEFINE
sec
rts
2015-10-06 16:14:48 +00:00
*---------------------------------------
2018-01-11 16:34:09 +00:00
SRC.ParseLine.SymP jsr SRC.GetNextChar
2015-10-09 15:53:30 +00:00
beq SRC.ParseLine.SymE
jsr SRC.GetDecimal
2015-11-20 16:31:14 +00:00
bcs SRC.ParseLine.SymE
2015-10-09 15:53:30 +00:00
jmp SYM.AddPrivate
*---------------------------------------
2018-01-11 16:34:09 +00:00
SRC.ParseLine.SymL jsr SRC.GetNextChar
2015-10-09 15:53:30 +00:00
beq SRC.ParseLine.SymE
jsr SRC.GetDecimal
2015-11-20 16:31:14 +00:00
bcs SRC.ParseLine.SymE
lda SRC.ACC+1
ora SRC.ACC+2
ora SRC.ACC+3
bne SRC.ParseLine.SymE Max .255
lda SRC.ACC
beq SRC.ParseLine.SymE .0 is not allowed
sta SRC.LLabel.ID
ldy #ASM.PC
lda (pData),y
ldy #ASM.PC.GLABEL
sec
sbc (pData),y
sta SRC.LLabel.Offset
ldy #ASM.PC+1
lda (pData),y
ldy #ASM.PC.GLABEL+1
sbc (pData),y
bne SRC.ParseLine.SymR
ldy #ASM.PC+2
lda (pData),y
ldy #ASM.PC.GLABEL+2
sbc (pData),y
bne SRC.ParseLine.SymR
ldy #ASM.PC+3
lda (pData),y
ldy #ASM.PC.GLABEL+3
sbc (pData),y
bne SRC.ParseLine.SymR
bcc SRC.ParseLine.SymR
jmp SYM.AddLToGBlock
*---------------------------------------
2018-01-11 16:34:09 +00:00
SRC.ParseLine.SymE lda #ERR.INV.LABEL
2015-11-20 16:31:14 +00:00
sec
rts
SRC.ParseLine.SymR lda #ERR.RANGE
sec
rts
2015-10-09 15:53:30 +00:00
*---------------------------------------
2015-11-20 16:31:14 +00:00
SRC.ParseLine.SymG >LDYA L.SRC.GLabel.Len
jsr SRC.GetLabel
2015-10-09 15:53:30 +00:00
bcs SRC.ParseLine.SymE
ldx #3 Makes Current Label = PC for now
2015-11-20 16:31:14 +00:00
ldy #ASM.PC+3
.1 lda (pData),y
sta SRC.GLabel.Value,x
2015-10-09 15:53:30 +00:00
dey
dex
bpl .1
2015-11-20 16:31:14 +00:00
ldx #3 Makes Current Label = Ref for next local
ldy #ASM.PC.GLABEL+3
.2 lda SRC.GLabel.Value,x
sta (pData),y
dey
dex
bpl .2
lda #$80 Mark GLabel Flag...
sta SRC.GLabel.Flags
sta SRC.GLabel.New
2015-10-09 15:53:30 +00:00
clc
rts
*---------------------------------------
2015-10-06 16:14:48 +00:00
SRC.ParseLine.Dir >LDYA L.T.DIRECTIVES
jsr SRC.GetKeyword
2018-01-11 16:34:09 +00:00
2015-10-06 16:14:48 +00:00
bcs .9
jmp (J.DIRECTIVES,x)
2018-01-11 16:34:09 +00:00
.9 lda #ERR.INV.DIRECTIVE
2015-10-06 16:14:48 +00:00
sec
rts
*---------------------------------------
2015-10-28 16:55:12 +00:00
SRC.ParseLine.Exec.Macro
2015-10-09 15:53:30 +00:00
clc
rts
*---------------------------------------
2015-10-28 16:55:12 +00:00
SRC.ParseLine.Add.Macro
2015-10-06 16:14:48 +00:00
clc
rts
*---------------------------------------
2015-10-28 16:55:12 +00:00
SRC.ParseLine.OpCode
2018-01-12 16:05:04 +00:00
ldy #ASM.T.hMem
2015-10-28 16:55:12 +00:00
lda (pData),y
>SYSCALL GetMemPtr.A
2015-10-28 16:55:12 +00:00
>STYA ZPPtr1
2018-01-11 16:34:09 +00:00
ldy #ASM.T.O setup Ptr2 to Opcodes
2015-10-28 16:55:12 +00:00
lda (ZPPtr1),y
clc
adc ZPPtr1
sta ZPPtr2
iny
lda (ZPPtr1),y
adc ZPPtr1+1
sta ZPPtr2+1
2018-01-11 16:34:09 +00:00
ldy #ASM.T.R setup Ptr3 to Registers
2015-10-30 16:34:59 +00:00
lda (ZPPtr1),y
clc
adc ZPPtr1
sta ZPPtr3
iny
lda (ZPPtr1),y
adc ZPPtr1+1
sta ZPPtr3+1
2018-01-11 16:34:09 +00:00
.10 lda (ZPPtr2) End Of OpCode List
2018-01-12 16:05:44 +00:00
ldy #1
ora (ZPPtr2),y
2015-10-28 16:55:12 +00:00
beq .9
2018-01-12 16:05:44 +00:00
lda ZPPtr2
clc
adc #2
sta ZPPtr1
lda ZPPtr2+1
adc #0
sta ZPPtr1+1
lda (ZPPtr1)
2018-01-11 16:34:09 +00:00
tax
ldy #0
2015-10-28 16:55:12 +00:00
2018-01-12 16:05:44 +00:00
>DEBUG
2018-01-11 16:34:09 +00:00
.1 lda (ZPLinePtr),y
2018-01-12 16:05:44 +00:00
cmp #'a'
bcc .11
cmp #'z'+1
bcs .11
eor #$20
.11 iny
cmp (ZPPtr1),y
2015-10-28 16:55:12 +00:00
bne .7
2018-01-11 16:34:09 +00:00
dex
2015-10-28 16:55:12 +00:00
bne .1
2015-10-30 16:34:59 +00:00
jsr SRC.ParseLine.AM
2015-11-27 16:26:11 +00:00
2015-12-17 16:57:35 +00:00
2015-11-27 16:26:11 +00:00
2015-10-30 16:34:59 +00:00
bcs .99
2015-12-17 16:57:35 +00:00
bcc .20
ldx SRC.AM.StrBuf
beq .20
ldx #0
.21 inx
lda SRC.AM.StrBuf,x
phx
>SYSCALL PutChar.A
2015-12-17 16:57:35 +00:00
plx
cpx SRC.AM.StrBuf
bne .21
lda #13
>SYSCALL PutChar.A
2015-12-17 16:57:35 +00:00
.20 ldy #ASM.PC
2015-11-20 16:31:14 +00:00
lda (pData),y
inc
sta (pData),y
bne .2
iny
lda (pData),y
inc
sta (pData),y
.2 clc
2015-10-28 16:55:12 +00:00
rts
2018-01-12 16:05:44 +00:00
.7 lda ZPPtr2
2015-10-28 16:55:12 +00:00
clc
adc (ZPPtr2)
tax
2018-01-12 16:05:44 +00:00
lda ZPPtr2+1
2015-10-28 16:55:12 +00:00
ldy #1
adc (ZPPtr2),y
stx ZPPtr2
sta ZPPtr2+1
bra .10
2018-01-11 16:34:09 +00:00
.9 lda #ERR.INV.OPCODE
2015-10-28 16:55:12 +00:00
sec
2015-10-30 16:34:59 +00:00
.99 rts
*---------------------------------------
SRC.ParseLine.AM stz SRC.AM.ID
stz SRC.AM.StrBuf
2018-01-11 16:34:09 +00:00
.1 jsr SRC.GetNextCharUC any arg immediately after ' '?
2015-10-30 16:34:59 +00:00
beq .8 no, AM.ID=0 (implied)
cmp #' ' another space ?
beq .8 ignore end of line (comment)
jsr SRC.IsAMReserved
bcs .2
inc SRC.AM.StrBuf
ldx SRC.AM.StrBuf
sta SRC.AM.StrBuf,x
bra .1
2015-11-20 16:31:14 +00:00
.8 clc
2015-10-28 16:55:12 +00:00
rts
2015-10-30 16:34:59 +00:00
2015-12-17 16:57:35 +00:00
.2 jsr SRC.IsMODReserved
bcs .21
lda #'#'
inc SRC.AM.StrBuf
ldx SRC.AM.StrBuf
sta SRC.AM.StrBuf,x
bra .1
.21 jsr SRC.IsLetter Any register?
2015-10-30 16:34:59 +00:00
bcs .70 no, try something else
2018-01-11 16:34:09 +00:00
ldx ZPLinePtr
stx SRC.LinePtrSave
ldx ZPLinePtr+1
stx SRC.LinePtrSave+1
2015-11-27 16:26:11 +00:00
2015-10-30 16:34:59 +00:00
stz SRC.AM.tmpBuf
sta SRC.AM.tmpBuf+1
inc SRC.AM.tmpBuf
2018-01-11 16:34:09 +00:00
.3 jsr SRC.GetNextCharUC
beq .4
2015-10-30 16:34:59 +00:00
jsr SRC.IsLetterOrDigit
2015-12-17 16:57:35 +00:00
bcs .4
2015-10-30 16:34:59 +00:00
inc SRC.AM.tmpBuf
ldx SRC.AM.tmpBuf
sta SRC.AM.tmpBuf,x
bra .3
2018-01-11 16:34:09 +00:00
.4 ldy #0
2015-10-30 16:34:59 +00:00
.5 lda (ZPPtr3),y
beq .71 last register ?
2015-11-13 16:25:31 +00:00
phy
2015-12-17 16:57:35 +00:00
ldx #$ff
2015-10-30 16:34:59 +00:00
.6 lda (ZPPtr3),y
iny
inx
cmp SRC.AM.tmpBuf,x
bne .7
cpx SRC.AM.tmpBuf
bne .6
2015-11-13 16:25:31 +00:00
ply
2015-10-30 16:34:59 +00:00
ldy #0 register match, add to AM string
ldx SRC.AM.StrBuf
.61 iny
lda SRC.AM.tmpBuf,y
inx
2015-11-20 16:31:14 +00:00
sta SRC.AM.StrBuf,x
2015-10-30 16:34:59 +00:00
cpy SRC.AM.tmpBuf
bne .61
2015-11-20 16:31:14 +00:00
2015-10-30 16:34:59 +00:00
stx SRC.AM.StrBuf
2015-12-17 16:57:35 +00:00
jmp .1
2015-10-30 16:34:59 +00:00
2015-11-13 16:25:31 +00:00
.7 ply
tya
sec
adc (ZPPtr3),y
tay
2015-10-30 16:34:59 +00:00
bra .5
2018-01-11 16:34:09 +00:00
.71 ldx SRC.LinePtrSave Does not match a register,restore Ptr
stx ZPLinePtr
stx SRC.LinePtrSave+1
stx ZPLinePtr+1
.70 jsr EXP.Eval
2015-12-17 16:57:35 +00:00
2015-10-30 16:34:59 +00:00
bcs .99
2015-12-17 16:57:35 +00:00
ldx #3
.73 lda SRC.ACC,x
bne .72
dex
bne .73
.72 inx
txa
ora #$30
inc SRC.AM.StrBuf
ldx SRC.AM.StrBuf
sta SRC.AM.StrBuf,x
jmp .1
2015-10-30 16:34:59 +00:00
clc
rts
2018-01-11 16:34:09 +00:00
.9 lda #ERR.INV.AM.SYN
2015-10-30 16:34:59 +00:00
sec
.99 rts
2015-10-28 16:55:12 +00:00
*---------------------------------------
2015-10-06 16:14:48 +00:00
SRC.GetDecimal stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
2018-01-11 16:34:09 +00:00
lda (ZPLinePtr)
2015-10-06 16:14:48 +00:00
beq .99
2018-01-11 16:34:09 +00:00
2015-10-06 16:14:48 +00:00
jsr SRC.IsDigit10
bcs .99
2018-01-11 16:34:09 +00:00
2015-10-06 16:14:48 +00:00
and #$0F
sta SRC.ACC
2018-01-11 16:34:09 +00:00
.1 jsr SRC.GetNextChar
2015-10-06 16:14:48 +00:00
beq .8
2018-01-11 16:34:09 +00:00
2015-10-06 16:14:48 +00:00
cmp #' '
2018-01-11 16:34:09 +00:00
beq .8
2015-11-27 16:26:11 +00:00
jsr SRC.IsEXPReserved
2018-01-11 16:34:09 +00:00
bcc .8
2015-11-27 16:26:11 +00:00
jsr SRC.IsAMReserved
2018-01-11 16:34:09 +00:00
bcc .8
2015-10-06 16:14:48 +00:00
jsr SRC.IsDigit10
2018-01-11 16:34:09 +00:00
bcs .9
2015-10-06 16:14:48 +00:00
and #$0F
pha
jsr SRC.ACC10
pla
bcs .9
2015-11-20 16:31:14 +00:00
2015-10-06 16:14:48 +00:00
adc SRC.ACC
sta SRC.ACC
bcc .1
inc SRC.ACC+1
bne .1
inc SRC.ACC+2
bne .1
inc SRC.ACC+3
bne .1
.9 lda #ERR.VAL.TOO.BIG
sec
rts
2015-11-27 16:26:11 +00:00
2015-10-06 16:14:48 +00:00
.8 clc
rts
2015-10-28 16:55:12 +00:00
.99 lda #ERR.SYNTAX.ERROR
sec
rts
*---------------------------------------
SRC.GetHex stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
2018-01-12 16:05:04 +00:00
jsr SRC.GetNextChar
2018-01-11 16:34:09 +00:00
lda (ZPLinePtr)
2015-10-28 16:55:12 +00:00
beq .99
jsr SRC.IsDigit16
bcs .99
2015-11-20 16:31:14 +00:00
2015-10-28 16:55:12 +00:00
sta SRC.ACC
2018-01-11 16:34:09 +00:00
.1 jsr SRC.GetNextChar
2015-10-28 16:55:12 +00:00
beq .8
cmp #' '
2018-01-11 16:34:09 +00:00
beq .8
2015-11-27 16:26:11 +00:00
jsr SRC.IsEXPReserved
2018-01-11 16:34:09 +00:00
bcc .8
2015-11-27 16:26:11 +00:00
jsr SRC.IsAMReserved
2018-01-11 16:34:09 +00:00
bcc .8
2015-10-28 16:55:12 +00:00
jsr SRC.IsDigit16
bcs .99
ldx #4
2015-11-20 16:31:14 +00:00
.2 asl SRC.ACC
2015-10-28 16:55:12 +00:00
rol SRC.ACC+1
rol SRC.ACC+2
rol SRC.ACC+3
bcs .9
dex
bne .2
2015-11-20 16:31:14 +00:00
ora SRC.ACC
sta SRC.ACC
2015-10-28 16:55:12 +00:00
bra .1
.8 clc
rts
.9 lda #ERR.VAL.TOO.BIG
sec
rts
2015-10-30 16:34:59 +00:00
.99 lda #ERR.SYNTAX.ERROR
sec
rts
*---------------------------------------
SRC.GetOctal stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
2018-01-12 16:05:04 +00:00
jsr SRC.GetNextChar
2018-01-11 16:34:09 +00:00
lda (ZPLinePtr)
2015-10-30 16:34:59 +00:00
beq .99
2018-01-11 16:34:09 +00:00
2015-10-30 16:34:59 +00:00
jsr SRC.IsDigit8
bcs .99
2018-01-11 16:34:09 +00:00
2015-10-30 16:34:59 +00:00
and #$0F
sta SRC.ACC
2018-01-11 16:34:09 +00:00
.1 jsr SRC.GetNextChar
2015-10-30 16:34:59 +00:00
beq .8
2018-01-11 16:34:09 +00:00
2015-10-30 16:34:59 +00:00
cmp #' '
2018-01-11 16:34:09 +00:00
beq .8
2015-11-27 16:26:11 +00:00
jsr SRC.IsEXPReserved
2018-01-11 16:34:09 +00:00
bcc .8
2015-11-27 16:26:11 +00:00
jsr SRC.IsAMReserved
2018-01-11 16:34:09 +00:00
bcc .8
2015-10-30 16:34:59 +00:00
jsr SRC.IsDigit8
2018-01-11 16:34:09 +00:00
bcs .9
2015-10-30 16:34:59 +00:00
asl
asl
asl
asl
asl
ldx #3
.2 asl
rol SRC.ACC
rol SRC.ACC+1
rol SRC.ACC+2
rol SRC.ACC+3
bcs .9
dex
bne .2
bra .1
.8 clc
rts
.9 lda #ERR.VAL.TOO.BIG
sec
rts
2015-10-28 16:55:12 +00:00
.99 lda #ERR.SYNTAX.ERROR
sec
rts
*---------------------------------------
SRC.GetBinary stz SRC.ACC+1
stz SRC.ACC+2
stz SRC.ACC+3
2018-01-12 16:05:04 +00:00
jsr SRC.GetNextChar
2018-01-11 16:34:09 +00:00
lda (ZPLinePtr)
2015-10-28 16:55:12 +00:00
beq .99
2018-01-11 16:34:09 +00:00
2015-10-28 16:55:12 +00:00
cmp #'1'
beq .10
2018-01-11 16:34:09 +00:00
2015-10-28 16:55:12 +00:00
cmp #'0'
bne .99
2018-01-11 16:34:09 +00:00
2015-10-28 16:55:12 +00:00
.10 and #$01
sta SRC.ACC
2018-01-11 16:34:09 +00:00
.1 jsr SRC.GetNextChar
2015-10-28 16:55:12 +00:00
beq .8
2018-01-11 16:34:09 +00:00
2015-11-27 16:26:11 +00:00
cmp #' '
2018-01-11 16:34:09 +00:00
beq .8
2015-11-27 16:26:11 +00:00
jsr SRC.IsEXPReserved
2018-01-11 16:34:09 +00:00
bcc .8
2015-11-27 16:26:11 +00:00
jsr SRC.IsAMReserved
2018-01-11 16:34:09 +00:00
bcc .8
2015-10-28 16:55:12 +00:00
cmp #'1'
beq .11
2018-01-11 16:34:09 +00:00
2015-10-28 16:55:12 +00:00
cmp #'0'
bne .8
.11 lsr
rol SRC.ACC
rol SRC.ACC+1
rol SRC.ACC+2
rol SRC.ACC+3
bcs .9
bra .1
.8 clc
rts
.9 lda #ERR.VAL.TOO.BIG
sec
rts
2015-10-06 16:14:48 +00:00
.99 lda #ERR.SYNTAX.ERROR
sec
rts
*---------------------------------------
2015-11-20 16:31:14 +00:00
SRC.GetLabel >STYA ZPPtr1
2015-12-17 16:57:35 +00:00
2018-01-11 16:34:09 +00:00
lda (ZPLinePtr)
2015-10-06 16:14:48 +00:00
beq .9
2015-12-17 16:57:35 +00:00
2015-10-06 16:14:48 +00:00
jsr SRC.IsLetter
bcs .9
ldy #1
2015-11-20 16:31:14 +00:00
sta (ZPPtr1),y
2018-01-11 16:34:09 +00:00
.1 jsr SRC.GetNextCharUC
2015-10-06 16:14:48 +00:00
beq .8
2015-11-20 16:31:14 +00:00
2015-12-17 16:57:35 +00:00
jsr SRC.IsLetterOrDigit
bcc .2
2015-10-06 16:14:48 +00:00
cmp #'.'
beq .2
2015-11-20 16:31:14 +00:00
cmp #'_'
beq .2
2015-12-17 16:57:35 +00:00
cmp #' '
2018-01-11 16:34:09 +00:00
beq .8
2015-11-20 16:31:14 +00:00
jsr SRC.IsEXPReserved
2018-01-11 16:34:09 +00:00
bcc .8
2015-11-27 16:26:11 +00:00
jsr SRC.IsAMReserved
2018-01-11 16:34:09 +00:00
bcc .8
2015-12-17 16:57:35 +00:00
.9 lda #ERR.SYNTAX.ERROR
sec
rts
2015-11-13 16:25:31 +00:00
2015-11-20 16:31:14 +00:00
.2 iny
sta (ZPPtr1),y
2015-11-13 16:25:31 +00:00
cpy #SRC.GLABEL.MAXLEN
2015-11-20 16:31:14 +00:00
bcc .1 if equ Carry is set
2018-01-11 16:34:09 +00:00
2015-11-13 16:25:31 +00:00
.8 tya
2015-11-20 16:31:14 +00:00
sta (ZPPtr1)
2015-10-06 16:14:48 +00:00
clc
rts
*---------------------------------------
2018-01-11 16:34:09 +00:00
SRC.GetKeyword >STYA ZPPtr1 KeyWord table
2015-10-06 16:14:48 +00:00
stz SRC.Keyword.ID
2018-01-11 16:34:09 +00:00
.1 lda (ZPPtr1)
beq .9 End Of table
2015-10-06 16:14:48 +00:00
2018-01-11 16:34:09 +00:00
tax KW len
2015-10-06 16:14:48 +00:00
2018-01-11 16:34:09 +00:00
.2 ldy #0
2015-10-06 16:14:48 +00:00
2018-01-11 16:34:09 +00:00
.3 lda (ZPLinePtr),y
beq .5
jsr SRC.IsLetter
bcs .5
2015-10-06 16:14:48 +00:00
2018-01-11 16:34:09 +00:00
iny
cmp (ZPPtr1),y
bne .5
2015-10-06 16:14:48 +00:00
2018-01-11 16:34:09 +00:00
dex
bne .3
2015-10-06 16:14:48 +00:00
2018-01-11 16:34:09 +00:00
lda (ZPLinePtr),y All chars match...
beq .4 End of Line ?
2015-10-06 16:14:48 +00:00
2018-01-11 16:34:09 +00:00
jsr SRC.IsLetter
bcc .5 Additional letters...
2015-10-06 16:14:48 +00:00
2018-01-11 16:34:09 +00:00
.4 lda ZPLinePtr
clc
adc (ZPPtr1)
sta ZPLinePtr
bcc .41
inc ZPLinePtr+1
.41 ldx SRC.Keyword.ID
2015-10-06 16:14:48 +00:00
clc
rts
2018-01-11 16:34:09 +00:00
.5 lda (ZPPtr1)
sec Add keyword Len+1
adc ZPPtr1
sta ZPPtr1
bcc .6
inc ZPPtr1+1
.6 inc SRC.Keyword.ID
inc SRC.Keyword.ID
bra .1
2015-10-06 16:14:48 +00:00
.9 sec
rts
*---------------------------------------
2015-10-30 16:34:59 +00:00
SRC.IsAMReserved ldx SRC.AM.RESERVED
.1 cmp SRC.AM.RESERVED,x
beq .8
dex
bne .1
sec
rts
.8 clc
rts
*---------------------------------------
2015-12-17 16:57:35 +00:00
SRC.IsMODReserved ldx SRC.MOD.RESERVED
.1 cmp SRC.MOD.RESERVED,x
beq .8
dex
bne .1
sec
rts
.8 clc
rts
*---------------------------------------
2015-10-30 16:34:59 +00:00
SRC.IsEXPReserved ldx SRC.EXP.RESERVED
.1 cmp SRC.EXP.RESERVED,x
beq .8
dex
bne .1
sec
rts
.8 clc
rts
*---------------------------------------
2015-10-06 16:14:48 +00:00
SRC.IsLetterOrDigit jsr SRC.IsDigit10
bcc SRC.IsLetterRTS
*---------------------------------------
SRC.IsLetter cmp #'A'
bcc .9
2015-11-13 16:25:31 +00:00
cmp #'Z'+1
2015-10-06 16:14:48 +00:00
bcc SRC.IsLetterRTS
cmp #'a'
bcc .9
2015-11-13 16:25:31 +00:00
cmp #'z'+1
2015-10-06 16:14:48 +00:00
rts CC if lowercase
.9 sec
SRC.IsLetterRTS rts
*---------------------------------------
2015-10-28 16:55:12 +00:00
SRC.IsDigit16 jsr SRC.IsDigit10
bcc .8
cmp #'A'
bcc .9
2015-11-20 16:31:14 +00:00
cmp #'F'+1
2015-10-28 16:55:12 +00:00
bcc .1
rts cc if ok, cs if not
2015-11-20 16:31:14 +00:00
.1 sbc #'A'-11 cc so A->10 (11-CC)
2015-10-28 16:55:12 +00:00
clc
.8 and #$0F
rts
.9 sec
rts
*---------------------------------------
2015-10-06 16:14:48 +00:00
SRC.IsDigit10 cmp #'0'
bcc .9
2015-10-28 16:55:12 +00:00
cmp #'9'+1
2015-10-06 16:14:48 +00:00
rts cc if ok, cs if not
2015-10-30 16:34:59 +00:00
.9 sec
rts
*---------------------------------------
SRC.IsDigit8 cmp #'0'
bcc .9
cmp #'7'+1
rts cc if ok, cs if not
2015-10-06 16:14:48 +00:00
.9 sec
rts
*---------------------------------------
2018-01-11 16:34:09 +00:00
SRC.CheckBlank lda (ZPLinePtr)
beq .9
cmp #' '
bne .9
.1 jsr SRC.GetNextChar
2015-10-06 16:14:48 +00:00
beq .9
2018-01-11 16:34:09 +00:00
2015-10-06 16:14:48 +00:00
cmp #' '
2018-01-11 16:34:09 +00:00
beq .1
clc
rts
.9 sec
rts
*---------------------------------------
SRC.GetNextCharNB jsr SRC.GetNextCharUC
beq .9
cmp #' '
beq SRC.GetNextCharNB
2015-10-06 16:14:48 +00:00
.9 rts
*---------------------------------------
2018-01-11 16:34:09 +00:00
SRC.GetNextCharUC jsr SRC.GetNextChar
2015-10-06 16:14:48 +00:00
beq .9
cmp #'a'
bcc .9
2015-10-30 16:34:59 +00:00
cmp #'z'+1
2015-10-06 16:14:48 +00:00
bcs .9
eor #$20 to Uppercase
.9 rts
*---------------------------------------
2018-01-11 16:34:09 +00:00
SRC.GetCharUC lda (ZPLinePtr)
2015-10-28 16:55:12 +00:00
beq .9
2018-01-11 16:34:09 +00:00
cmp #'a'
bcc .9
cmp #'z'+1
bcs .9
eor #$20 to Uppercase
.9 rts
*---------------------------------------
SRC.GetNextChar lda (ZPLinePtr)
beq .9
inc ZPLinePtr
bne .1
inc ZPLinePtr+1
.1 lda (ZPLinePtr)
2015-10-28 16:55:12 +00:00
.9 rts
2015-10-06 16:14:48 +00:00
*---------------------------------------
SRC.ACC10 lda SRC.ACC ACC*2-> ACC & ACCTMP
asl
sta SRC.ACC
sta SRC.ACCTMP
lda SRC.ACC+1
rol
sta SRC.ACC+1
sta SRC.ACCTMP+1
lda SRC.ACC+2
rol
sta SRC.ACC+2
sta SRC.ACCTMP+2
lda SRC.ACC+3
rol
sta SRC.ACC+3
sta SRC.ACCTMP+3
bcs .9
2015-11-20 16:31:14 +00:00
ldx #2
.1 asl SRC.ACC ACC=ACC*4
2015-10-06 16:14:48 +00:00
rol SRC.ACC+1
rol SRC.ACC+2
rol SRC.ACC+3
bcs .9
dex
bne .1
lda SRC.ACC CC from ROL SRC.ACC+3
adc SRC.ACCTMP
sta SRC.ACC
lda SRC.ACC+1
adc SRC.ACCTMP+1
sta SRC.ACC+1
lda SRC.ACC+2
adc SRC.ACCTMP+2
sta SRC.ACC+2
lda SRC.ACC+3
adc SRC.ACCTMP+3
sta SRC.ACC+3 CS if overflow
.9 rts
*---------------------------------------
MAN
SAVE /A2OSX.BUILD/BIN/DEV/ASM.S.SRC
LOAD /A2OSX.BUILD/BIN/DEV/ASM.S
2015-10-06 16:14:48 +00:00
ASM