diff --git a/.Floppies/A2OSX.BUILD.po b/.Floppies/A2OSX.BUILD.po index 7092d058..50b8a74b 100644 Binary files a/.Floppies/A2OSX.BUILD.po and b/.Floppies/A2OSX.BUILD.po differ diff --git a/BIN/ASM.S.EXP.txt b/BIN/ASM.S.EXP.txt index 9bf13256..58518fc1 100644 --- a/BIN/ASM.S.EXP.txt +++ b/BIN/ASM.S.EXP.txt @@ -27,12 +27,12 @@ EXP.Eval.Missing lda #ERR.MISSING.EXP sec rts -EXP.Eval.Next jsr SRC.GetNextCharUC +EXP.Eval.Next jsr SRC.GetNextChar bcs EXP.Eval.Missing EXP.Eval.Next1 cmp #'.' Local Label? bne .12 - + jsr EXP.GetLocal bcs .14 @@ -156,7 +156,10 @@ EXP.EvalOperator lda EXP.Operator jmp EXP.Eval.Next *--------------------------------------- -EXP.GetLocal jsr SRC.GetDecimal +EXP.GetLocal jsr SRC.GetNextChar + bcs .9 + + jsr SRC.GetDecimal bcs EXP.EvalExitSYN lda SRC.ACC+1 ora SRC.ACC+2 @@ -164,9 +167,14 @@ EXP.GetLocal jsr SRC.GetDecimal bne EXP.EvalExitSYN Max .255 lda SRC.ACC beq EXP.EvalExitSYN .0 is not allowed + jsr SYM.GetLocal bcs EXP.EvalExitUND rts + +.9 lda #ERR.SYNTAX.ERROR + sec + rts *--------------------------------------- EXP.SetAccA sta SRC.ACC stz SRC.ACC+1 diff --git a/BIN/ASM.S.SRC.txt b/BIN/ASM.S.SRC.txt index 355b9ad7..62286d2e 100644 --- a/BIN/ASM.S.SRC.txt +++ b/BIN/ASM.S.SRC.txt @@ -56,6 +56,7 @@ SRC.PrintLineErr >PUSHW ZPLineBuf .9 rts *--------------------------------------- SRC.ParseLine lda #0 + sta (ZPLocalBuf) >STA.G SYM.bGlobal jsr SRC.GetChar @@ -84,7 +85,7 @@ SRC.ParseLine lda #0 lda SRC.ACC beq SRC.ParseLine.InvLbl .0 is not allowed - jsr SYM.AddLocal + jsr SYM.AddLocalPC bra .7 @@ -165,6 +166,8 @@ SRC.ParseLine.Add.Macro rts *--------------------------------------- SRC.ParseLine.OpCode + stz SRC.AM.ID + >LDYA ZPOPtr >STYA ZPPtr1 @@ -187,6 +190,7 @@ SRC.ParseLine.OpCode ldy #0 .2 lda (ZPLinePtr),y + beq .7 cmp #'a' bcc .3 @@ -197,37 +201,28 @@ SRC.ParseLine.OpCode .3 iny cmp (ZPPtr2),y - bne .4 + bne .7 dex bne .2 - iny lda (ZPLinePtr),y beq .8 End of Line, no AM - jsr SRC.IsLetterOrDigit - bcc .4 + cmp #' ' A space after opcode ? + bne .7 tya - clc + sec skip OP + ' ' adc ZPLinePtr sta ZPLinePtr bcc .5 inc ZPLinePtr+1 -.5 +.5 bra SRC.ParseLine.AM - jsr SRC.ParseLine.AM - rts - - - -.8 clc - rts - -.4 lda ZPPtr1 +.7 lda ZPPtr1 clc adc (ZPPtr1) tax @@ -238,17 +233,19 @@ SRC.ParseLine.OpCode sta ZPPtr1+1 bra .1 +.8 clc + rts + .9 lda #ERR.INV.OPCODE sec .99 rts *--------------------------------------- -SRC.ParseLine.AM stz SRC.AM.ID - stz SRC.AM.StrBuf +SRC.ParseLine.AM stz SRC.AM.StrBuf -.1 jsr SRC.GetNextCharUC any arg immediately after ' '? - bcs .8 no, AM.ID=0 (implied) - - cmp #' ' another space ? +.1 jsr SRC.GetChar + bcs .8 + +.10 cmp #' ' another space ? beq .8 ignore end of line (comment) jsr SRC.IsAMReserved @@ -257,89 +254,44 @@ SRC.ParseLine.AM stz SRC.AM.ID inc SRC.AM.StrBuf ldx SRC.AM.StrBuf sta SRC.AM.StrBuf,x - bra .1 - -.8 clc - rts + bra .7 .2 jsr SRC.IsMODReserved - bcs .21 + bcs .3 + lda #'#' inc SRC.AM.StrBuf ldx SRC.AM.StrBuf sta SRC.AM.StrBuf,x + bra .7 + +.3 jsr SRC.IsLetter Any register? + bcs .6 no, try something else + + >LDYA ZPRPtr + jsr SRC.GetKeyword + bcs .6 + + lda (ZPPtr1) get register len + tax + + ldy SRC.AM.StrBuf + +.4 inc ZPPtr1 + bne .5 + inc ZPPtr1+1 + +.5 lda (ZPPtr1) + iny + sta SRC.AM.StrBuf,y + dex + bne .4 + + sty SRC.AM.StrBuf + bra .1 -.21 jsr SRC.IsLetter Any register? - bcs .70 no, try something else - - ldx ZPLinePtr - stx SRC.LinePtrSave - ldx ZPLinePtr+1 - stx SRC.LinePtrSave+1 - - stz SRC.AM.tmpBuf - sta SRC.AM.tmpBuf+1 - inc SRC.AM.tmpBuf - -.3 jsr SRC.GetNextCharUC - bcs .4 - - jsr SRC.IsLetterOrDigit - bcs .4 - - inc SRC.AM.tmpBuf - ldx SRC.AM.tmpBuf - sta SRC.AM.tmpBuf,x - bra .3 - -.4 ldy #0 - -.5 lda (ZPPtr3),y - beq .71 last register ? - - phy - ldx #$ff - -.6 lda (ZPPtr3),y - iny - inx - cmp SRC.AM.tmpBuf,x - bne .7 - - cpx SRC.AM.tmpBuf - bne .6 - - ply - - ldy #0 register match, add to AM string - ldx SRC.AM.StrBuf - -.61 iny - lda SRC.AM.tmpBuf,y - inx - sta SRC.AM.StrBuf,x - cpy SRC.AM.tmpBuf - bne .61 - - stx SRC.AM.StrBuf - jmp .1 - -.7 ply - tya - sec - adc (ZPPtr3),y - tay - bra .5 - -.71 ldx SRC.LinePtrSave Does not match a register,restore Ptr - stx ZPLinePtr - stx SRC.LinePtrSave+1 - stx ZPLinePtr+1 - - -.70 jsr EXP.Eval - +.6 jsr EXP.Eval bcs .99 ldx #3 @@ -349,18 +301,24 @@ SRC.ParseLine.AM stz SRC.AM.ID bne .73 .72 inx - txa - ora #$30 - inc SRC.AM.StrBuf - ldx SRC.AM.StrBuf - sta SRC.AM.StrBuf,x + lda #'a' - jmp .1 - clc - rts + ldy SRC.AM.StrBuf + +.71 iny + sta SRC.AM.StrBuf,y + dex + bne .71 + sty SRC.AM.StrBuf + bra .1 +.7 jsr SRC.GetNextChar + bcc .10 +.8 clc + rts + .9 lda #ERR.INV.AM.SYN sec .99 rts @@ -593,7 +551,7 @@ SRC.GetKeyword >STYA ZPPtr1 KeyWord table .3 lda (ZPLinePtr),y beq .5 - jsr SRC.IsLetter + jsr SRC.IsLetterUC bcs .5 iny @@ -666,6 +624,22 @@ SRC.IsEXPReserved ldx SRC.EXP.RESERVED .8 clc rts *--------------------------------------- +SRC.IsLetterUC cmp #'A' + bcc .9 + cmp #'Z'+1 + bcc .99 + + cmp #'a' + bcc .9 + cmp #'z'+1 + + eor #$20 + + rts CC if lowercase + +.9 sec +.99 rts +*--------------------------------------- SRC.IsLetterOrDigit jsr SRC.IsDigit10 bcc SRC.IsLetterRTS *--------------------------------------- diff --git a/BIN/ASM.S.SYM.txt b/BIN/ASM.S.SYM.txt index e69087a8..ba16a4ad 100644 --- a/BIN/ASM.S.SYM.txt +++ b/BIN/ASM.S.SYM.txt @@ -30,11 +30,43 @@ SYM.Init >SYSCALL SListNew bcs .9 >STA.G SYM.hGlobals + + >LDYAI 256 + >SYSCALL GetMem.YA + bcs .9 + + >STYA ZPLocalBuf + txa + >STA.G SYM.hLocalBuf + + >LDYAI 256 + >SYSCALL GetMem.YA + bcs .9 + + >STYA ZPMacroBuf + txa + >STA.G MAC.hBuf + + .9 rts *--------------------------------------- -SYM.Quit >LDA.G SYM.hGlobals +SYM.Quit >LDA.G MAC.hBuf + beq .1 + + >SYSCALL FreeMem.A + +.1 >LDA.G SYM.hLocalBuf + beq .2 + + >SYSCALL FreeMem.A + +.2 >LDA.G SYM.hGlobals + beq .8 >SYSCALL SListFree.A - rts + + +.8 clc + rts *--------------------------------------- SYM.Dump >LDYA L.MSG.SYMBOLS >SYSCALL PrintF.YA @@ -171,8 +203,85 @@ SYM.UpdateGlobal lda #SYM.F.RESOLVED >SYSCALL SListUpdateByID rts *--------------------------------------- -SYM.AddLocal +SYM.AddLocalPC tax Save ID + + >LDA.G SYM.LocalIndex + tay clc + adc #6 + bcs .9 + + txa Get Back ID + sta (ZPLocalBuf),y + + iny + lda #SYM.F.RESOLVED + sta (ZPLocalBuf),y + + iny + phy + + ldx #4 + + ldy #ASM.PC+3 + +.1 lda (pData),y + pha + dey + dex + bne .1 + + ldx #4 + + ply + +.2 pla + sta (ZPLocalBuf),y + iny + dex + bne .2 + + lda #0 + sta (ZPLocalBuf),y + tya + >STA.G SYM.LocalIndex + +* clc + rts + +.9 lda #ERR.TOO.MANY.LOCAL +* sec + rts +*--------------------------------------- +SYM.AddLocalPending tax Save ID + + >LDA.G SYM.LocalIndex + tay + clc + adc #6 + bcs .9 + + txa Get Back ID + sta (ZPLocalBuf),y + + ldx #6 F+DWORD+Ending 0 + + lda #0 + +.1 iny + sta (ZPLocalBuf),y + + iny + dex + bne .1 + + >STA.G SYM.LocalIndex + +* clc + rts + +.9 lda #ERR.TOO.MANY.LOCAL +* sec rts *--------------------------------------- SYM.GetLocal diff --git a/BIN/ASM.S.txt b/BIN/ASM.S.txt index 10c1867d..73fa369c 100644 --- a/BIN/ASM.S.txt +++ b/BIN/ASM.S.txt @@ -14,8 +14,8 @@ ZPPtr2 .EQ ZPBIN+2 ZPPtr3 .EQ ZPBIN+4 ZPLineBuf .EQ ZPBIN+6 ZPLinePtr .EQ ZPBIN+8 -ZPBlockPtr .EQ ZPBIN+10 -ZPSymbolPtr .EQ ZPBIN+12 +ZPLocalBuf .EQ ZPBIN+10 +ZPMacroBuf .EQ ZPBIN+12 ZPTmpBuf .EQ ZPBIN+14 ZPAMPtr .EQ ZPBIN+16 ZPRPtr .EQ ZPBIN+18 @@ -23,8 +23,8 @@ ZPOPtr .EQ ZPBIN+20 *--------------------------------------- SYM.LEN .EQ 0 SYM.F .EQ 1 -SYM.F.RESOLVED .EQ %1000000 -SYM.F.RW .EQ %0100000 +SYM.F.RESOLVED .EQ %10000000 +SYM.F.RW .EQ %01000000 SYM.V .EQ 2 *--------------------------------------- ASM.T.AM .EQ 0 @@ -51,6 +51,7 @@ ERR.RANGE .EQ $A9 ERR.UNDEF.SYMBOL .EQ $AA ERR.SYMBOL.REDEF .EQ $AB ERR.TOO.MANY.DO .EQ $AC +ERR.TOO.MANY.LOCAL .EQ $AD ERR.MISSING.EXP .EQ $B0 ERR.EXP.SYN.ERROR .EQ $B1 ERR.INV.MACRO.DEF .EQ $E0 @@ -389,14 +390,12 @@ EXP.Operator .BS 1 EXP.Modifier .BS 1 SRC.LINENUM .BS 2 -SRC.LinePtrSave .BS 2 SRC.Keyword.ID .BS 1 SRC.ACC .BS 4 SRC.ACCTMP .BS 4 SRC.ARG .BS 4 SRC.AM.ID .BS 1 SRC.AM.StrBuf .BS 32 -SRC.AM.tmpBuf .BS 32 *-------------------------------------- .DUMMY .OR 0 @@ -439,8 +438,15 @@ ASM.LOCAL.INVALID .BS 1 SYM.hGlobals .BS 1 SYM.bGlobal .BS 1 SYM.Global .BS 6 -SYM.Lookup .BS 6 SYM.ID .BS 2 + +SYM.hLocalBuf .BS 1 +SYM.LocalIndex .BS 1 + +SYM.Lookup .BS 6 + +MAC.hBuf .BS 1 + DS.END .ED *--------------------------------------- .DO DS.END-DS.START>$FF