summaryrefslogtreecommitdiff
path: root/programs/sub-suite/lexer.s
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-08-08 18:11:35 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-08-08 18:11:35 -0400
commitf16af793a58a9f398fc598a0c129e3bb90eb61f6 (patch)
tree2f674574f2955a1bc52ee3a6818516226833ea9b /programs/sub-suite/lexer.s
parent1ec19679b3db209429b0897f6ccda6d09d018a70 (diff)
- Refactored the opcode table, in order to make the
instruction formatting simpler. - Refactored the instruction table of the emulator's assembler, it now has two parts, the addressing mode bits, and the base value. The base value is what's used to generate the actual opcode, with the addressing mode bits telling the assembler what addressing modes this instruction supports. The reason for doing this was to use less space. For comparison, the previous version used 870 bytes for the instruction table, while the new version uses only 222 bytes. The new version is nearly 4 times smaller than the pervious version. - The B register based ALU instructions now use their own addressing mode, and are specified by using 'b' as the operand for those instructions. For example, to add the Accumulator with the B register, you now use "ADC B" instead of "AAB".
Diffstat (limited to 'programs/sub-suite/lexer.s')
-rw-r--r--programs/sub-suite/lexer.s26
1 files changed, 13 insertions, 13 deletions
diff --git a/programs/sub-suite/lexer.s b/programs/sub-suite/lexer.s
index c144f9a..dc5a3b0 100644
--- a/programs/sub-suite/lexer.s
+++ b/programs/sub-suite/lexer.s
@@ -8,7 +8,7 @@ lex:
sty.q idx0 ; Clear the first index.
sty.q idx1 ; Clear the second index.
sty.q idx2 ; Clear the third index.
- sty b ; Clear the isop flag.
+ sty regb ; Clear the isop flag.
; lda (ptr), y ; Get a character from the line.
; pha ; Preserve the character.
; jsr isdigit ; Is this character a digit?
@@ -99,7 +99,7 @@ ptok_dot:
ldb #$11 ; Set the delimiter comparison value to whitespace.
jsr delmcpy ; Copy the string, to the lexeme buffer, until delimiter.
@isop:
- lda b ; Has the isop flag been set?
+ lda regb ; Has the isop flag been set?
beq @dir ; No, so check for a directive.
@rs:
lda #TOK_RS ; Yes, so set the lexeme type to TOK_RS.
@@ -248,7 +248,7 @@ ptok_alph:
tba ; Use isdelm2 for the comparison.
jsr delmcpy ; Copy the string, to the lexeme buffer, until delimiter.
lda #0 ; Reset A.
- sta b ; Clear the isop flag.
+ sta regb ; Clear the isop flag.
@isop:
ldb #0 ; Make the lexeme buffer, the first pointer.
stb.q idx1 ; Reset the second index.
@@ -272,7 +272,7 @@ ptok_alph:
@found:
lda #TOK_MNE ; Set the lexeme type to TOK_MNE.
sta lex_type ;
- inc b ; Set the isop flag.
+ inc regb ; Set the isop flag.
@end:
jsr make_tok ; Create the token.
jsr set_cmdbuf ; Set the first pointer to the command buffer.
@@ -325,23 +325,23 @@ init_lex:
delmcpy:
- sta a ; Save the delimiter check flag.
- stb c ; Save the delimiter comparison value.
+ sta rega ; Save the delimiter check flag.
+ stb regc ; Save the delimiter comparison value.
@loop:
ldb #0 ; Reset the B register.
- stb g ; Reset the byte count.
+ stb regg ; Reset the byte count.
ldy.w idx0 ; Get the string index.
lda.q (ptr), y ; Get eight bytes from the current line.
@loop1:
pha.q ; Save the string buffer.
and #$FF ; Get the current byte.
pha ; Preserve the character.
- lda a ; Are we calling isdelm2?
+ lda rega ; Are we calling isdelm2?
pla ; Get the character back.
bne @isdelm2 ; Yes, so use isdelm2.
jsr isdelm ; No, so get the delimiter value from isdelm.
@delmchk:
- and c ; Are both delimiter values, the same?
+ and regc ; Are both delimiter values, the same?
pla.q ; Get back the string buffer.
bne @end ; Yes, so we're done.
bra @copy ; No, so start copying the character.
@@ -354,8 +354,8 @@ delmcpy:
inc.w idx0 ; Increment the string index.
inc.w idx1 ; Increment the lexeme index.
lsr #8 ; Shift in the next byte.
- inc g ; Increment the byte count.
- ldb g ; Get back the byte count.
+ inc regg ; Increment the byte count.
+ ldb regg ; Get back the byte count.
cpb #7 ; Did we shift in eight bytes?
beq @loop ; Yes, so get eight more bytes.
bra @loop1 ; No, so keep shifting in more bytes.
@@ -372,12 +372,12 @@ delmcpy:
; ldy.w idx0 ; Get the string index.
; lda (ptr), y ; Get a character from the line.
; pha ; Preserve the character.
-; lda a ; Are we calling isdelm2?
+; lda rega ; Are we calling isdelm2?
; pla ; Get the character back.
; bne @isdelm2 ; Yes, so use isdelm2.
; jsr isdelm ; No, so get the delimiter value from isdelm.
;@delmchk:
-; and c ; Are both delimiter values, the same?
+; and regc ; Are both delimiter values, the same?
; bne @end ; Yes, so we're done.
; bra @copy ; No, so start copying the character.
;@isdelm2: