From 756c606af68be8ccca7aced3b9c3d56fb2d5087f Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Mon, 6 Jul 2020 20:04:41 -0400 Subject: - Implemented a new opcode table. - Added a new preifx called the OF prefix, which adds the contents of a specific register to the current operand. - Added a table generator, which parses opcode table csv files. --- programs/sub-suite/subasm.s | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'programs/sub-suite/subasm.s') diff --git a/programs/sub-suite/subasm.s b/programs/sub-suite/subasm.s index 9c6c3f0..d661695 100644 --- a/programs/sub-suite/subasm.s +++ b/programs/sub-suite/subasm.s @@ -187,6 +187,14 @@ idx2: idx3: .qword 0 +; Value buffer used by strtoull. +valbuf: + .qword 0 + +; Copy buffer used by delmcpy. +cpybuf: + .qword 0 + ; Current token line. ctok: .word 0 @@ -225,7 +233,7 @@ subasm: jsr chk_cmd ; No, but did we get a full command? bne @cmd ; Yes, so skip everything else. jsr lex ; No, so start lexing this line. - jmp @end ; We are done. + bra @end ; We are done. @cmd: ldb #1 ; Set the second pointer lda.d #cmd_srt ; to the command subroutine table. @@ -236,10 +244,10 @@ subasm: cmp #8 ; Is the command ID greater than the command count? bcs @end ; Yes, so we're done. lsl #1 ; No, so multiply the command ID by two. - phy #2 ; Preserve the screen buffer position. + phy.w ; Preserve the screen buffer position. tay ; Set the index to the offset that we just calculated. lda.w (ptr2), y ; Get the command subroutine, from the command subroutine table. - ply #2 ; Get back the screen buffer position. + ply.w ; Get back the screen buffer position. ldb #2 ; Save it in the third pointer. jsr set_ptr ; ldb #0 ; Reset B. @@ -254,7 +262,7 @@ chk_shcmd: jsr set_ptr ; deb ; Reset B. tba ; Reset A. - phy #2 ; Preserve the screen buffer position. + phy.w ; Preserve the screen buffer position. txy ; Set our index to zero. lda (ptr), y ; Is there nothing in the command buffer? beq @false ; Yes, so return that we failed. @@ -267,7 +275,7 @@ chk_shcmd: cab ; No, so did the character match? beq @found ; Yes, so check if there are any arguments. iny ; No, so check the next command. - jmp @loop ; Keep looping. + bra @loop ; Keep looping. @found: sty f ; Save the command ID. ldy #1 ; Check the next character in the command buffer. @@ -275,16 +283,16 @@ chk_shcmd: beq @true ; Yes, so return that we succeded. cmp #' ' ; No, but is this a space? beq @true ; Yes, so return that we succeded. - jmp @false ; No, so return that we failed. + bra @false ; No, so return that we failed. @true: lda #1 ; Return true. - jmp @end ; We are done. + bra @end ; We are done. @false: ldb #0 ; Reset B. tba ; Return false. tax ; Reset X. @end: - ply #2 ; Get back the screen buffer position. + ply.w ; Get back the screen buffer position. rts ; End of chk_shcmd. @@ -297,9 +305,9 @@ chk_cmd: lda.w #cmds ; Get pointer to the start of the command table. clc ; Prepare for a non carrying add. adc.w idx0 ; Offset the pointer, by the length of the previous string. - pha #8 ; Preserve the command string pointer. + pha.q ; Preserve the command string pointer. jsr strcasecmp ; Is the command buffer, the same as the command string? - pla #8 ; Get the command string pointer back. + pla.q ; Get the command string pointer back. beq @true ; Yes, so return true. ldb idx1 ; No, so Get the command ID. cpb #7 ; Have we reached the end of the command table? @@ -312,12 +320,12 @@ chk_cmd: clc ; Prepare for a non carrying add. adc.w idx0 ; Add the string offset to the current length sta.w idx0 ; Save the offset in the first index. - jmp @loop ; Keep looping. + bra @loop ; Keep looping. @true: ldb idx1 ; Get the command ID. stb f ; Return the command ID. ldb #1 ; Return true. - jmp @end ; We are done. + bra @end ; We are done. @false: ldb #0 ; Return false. @end: @@ -351,7 +359,7 @@ viewmem: adc #$10 ; Add 16 to the address. sta.q idx0 ; Put it back into the address. and #0 ; Reset A. - jmp @loop ; Keep looping. + bra @loop ; Keep looping. @end: lda #'\n' ; Print a newline. jsr print_char ; -- cgit v1.2.3-13-gbd6f