From df81112b8369eeca5788a6f28c6b6b85ca911a95 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Mon, 1 Jun 2020 15:15:17 -0400 Subject: Did some more refactoring to the assembler. - Refactored the symbol, and fixup table to now use a linked list - Added support for local symbols to the assembler. - Rewrote SuBEditor, and SuBAsm to use local symbols. --- programs/subasm.s | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'programs/subasm.s') diff --git a/programs/subasm.s b/programs/subasm.s index 86a8837..e009ce8 100644 --- a/programs/subasm.s +++ b/programs/subasm.s @@ -218,7 +218,7 @@ subasm: tax ; Reset X. jsr chk_shcmd ; Did we get a shortend command? bne parse_cmd ; Yes, so skip everything else. - jmp subasm_end ; + jmp @end ; jsr chk_cmd ; No, but did we get a full command? bne parse_cmd ; Yes, so skip everything else. jsr lexer ; No, so start lexing this line. @@ -255,32 +255,32 @@ chk_shcmd: phy #2 ; Preserve the screen buffer position. txy ; Set our index to zero. lda (ptr), y ; Is there nothing in the command buffer? - beq shcmd_fail ; Yes, so return that we failed. + beq @false ; Yes, so return that we failed. cmp #' ' ; No, but is this character, a space? - beq shcmd_fail ; Yes, so return that we failed. -shcmd_loop: + beq @false ; Yes, so return that we failed. +@loop: ldb (ptr2), y ; Are we at the end of the table? - beq shcmd_fail ; Yes, so return that we failed. + beq @false ; Yes, so return that we failed. cab ; No, so did the character match? - beq shcmd_fnd ; Yes, so check if there are any arguments. + beq @found ; Yes, so check if there are any arguments. iny ; No, so check the next command. - jmp shcmd_loop ; Keep looping. -shcmd_fnd: + jmp @loop ; Keep looping. +@found: sty f ; Save the command ID. ldy #1 ; Check the next character in the command buffer. lda (ptr), y ; Is this the end of the buffer? - beq shcmd_true ; Yes, so return that we succeded. + beq @true ; Yes, so return that we succeded. cmp #' ' ; No, but is this a space? - beq shcmd_true ; Yes, so return that we succeded. - jmp shcmd_fail ; No, so return that we failed. -shcmd_true: + beq @true ; Yes, so return that we succeded. + jmp @false ; No, so return that we failed. +@true: lda #1 ; Return true. - jmp shcmd_end ; We are done. -shcmd_fail: + jmp @end ; We are done. +@false: ldb #0 ; Reset B. tba ; Return false. tax ; Reset X. -shcmd_end: +@end: ply #2 ; Get back the screen buffer position. rts ; End of chk_shcmd. @@ -297,7 +297,7 @@ viewmem: ldx #0 ; Reset X. ldb #0 ; Reset B. stb idx1 ; Reset the byte count. -vmem_lp0: +@loop: lda #'\n' ; Print a newline. jsr print_char ; jsr print_hi ; Place the address in the string buffer. @@ -307,14 +307,14 @@ vmem_lp0: inc idx1 ; Increment the chunk count. ldb idx1 ; Get the chunk count. cpb #$10 ; Did we print 16 chunks? - beq vmem_end ; Yes, so we're done. + beq @end ; Yes, so we're done. lda.q idx0 ; No, so get the address index. clc ; Prepare for a non carrying add. adc #$10 ; Add 16 to the address. sta.q idx0 ; Put it back into the address. and #0 ; Reset A. - jmp vmem_lp0 ; Keep looping. -vmem_end: + jmp @loop ; Keep looping. +@end: lda #'\n' ; Print a newline. jsr print_char ; and #0 ; Reset A. @@ -323,27 +323,27 @@ vmem_end: list: nop ; -list_end: +@end: rts ; End of list. asm: nop ; -asm_end: +@end: rts ; End of asm. help: nop ; -help_end: +@end: rts ; End of help. inst: nop ; -inst_end: +@end: rts ; End of inst. run: nop ; -run_end: +@end: rts ; End of run. set: nop ; -set_end: +@end: rts ; End of set. -- cgit v1.2.3-13-gbd6f