summaryrefslogtreecommitdiff
path: root/programs/sub-suite/lexer.s
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-02-25 12:43:11 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2021-02-25 12:43:11 -0500
commit35a18609864470b3dc49f3a9a6cb6ec93e57300d (patch)
treec52364211b25723b2cf4595ed6c4bc2d45195062 /programs/sub-suite/lexer.s
parent8d7f27d9a0b61d3694a62f3e54be885d8073f02b (diff)
- Implemented the multiply expression into the assembler.
- Implemented support for the SIB addressing mode into the assembler. SIB is short for "Scale Index, and Base", and works much like x86's version of SIB (scale*index+base), although my version supports any scale value between 1, and 256. - Redid the line shifting routine in SuBEditor. It now uses memcpy, and memset to do that, and also supports shifting the line left, or right by any number of characters.
Diffstat (limited to 'programs/sub-suite/lexer.s')
-rw-r--r--programs/sub-suite/lexer.s48
1 files changed, 11 insertions, 37 deletions
diff --git a/programs/sub-suite/lexer.s b/programs/sub-suite/lexer.s
index 0d712ff..320a582 100644
--- a/programs/sub-suite/lexer.s
+++ b/programs/sub-suite/lexer.s
@@ -310,21 +310,7 @@ ptok_dqu:
lda #TOK_DQUOT ; Set the lexeme type to TOK_DQUOT.
sta lex_type ;
sta t_id ; Also set the token ID to TOK_DQUOT.
-; lda.d ptr3 ; Get the address of the lexeme buffer.
- lda.q idx1 ; Get the index of the lexeme buffer.
- inc ; Increment it by one to get the size.
- jsr malloc ; Make a new string.
- ldb.q ptr3 ; Get the address of the lexeme buffer.
- ldy.q idx1 ; Get the size of the lexeme buffer + 1.
- iny ;
- jsr memcpy ; Copy the string in the lexeme buffer into the new string.
- sta.q t_str ; Save it in the token string.
- and #0 ; Reset A.
- tab ; Reset B.
- ldy.q idx0 ; Get the string index back.
-@end:
- jsr make_tok ; Create the token.
- rts ; End of parse_ptok.
+ bra copy_str ; Copy the string.
ptok_squ:
ldb #1 ; Make init_lex increment the string index.
jsr init_lex ; Initialize the lexeme buffer for copying.
@@ -337,23 +323,7 @@ ptok_squ:
lda #TOK_SQUOT ; Set the lexeme type to TOK_SQUOT.
sta lex_type ;
sta t_id ; Also set the token ID to TOK_SQUOT.
- lda.q idx1 ; Get the index of the lexeme buffer.
- inc ; Increment it by one to get the size.
- jsr malloc ; Make a new string.
- ldb.q ptr3 ; Get the address of the lexeme buffer.
- ldy.q idx1 ; Get the size of the lexeme buffer + 1.
- iny ;
- jsr memcpy ; Copy the string in the lexeme buffer into the new string.
- sta.q t_str ; Save it in the token string.
- and #0 ; Reset A.
- tab ; Reset B.
- ldy.q idx0 ; Get the string index back.
-@end:
- jsr make_tok ; Create the token.
- rts ; End of parse_ptok.
-ptok_hash:
- inc.w idx0 ;
- rts ; End of parse_ptok.
+ bra copy_str ; Copy the string.
ptok_scol:
ldb #1 ; Make init_lex increment the string index.
jsr init_lex ; Initialize the lexeme buffer for copying.
@@ -365,12 +335,13 @@ ptok_scol:
lda #TOK_SCOLN ; Set the lexeme type to TOK_SCOLN.
sta lex_type ;
sta t_id ; Also set the token ID to TOK_SCOLN.
- lda.q idx1 ; Get the index of the lexeme buffer.
- inc ; Increment it by one to get the size.
+copy_str:
+ lea d, (idx1) ; Get the index of the lexeme buffer.
+ inc d ; Increment it by one to get the size.
+ mov f, d ; Get the size of the lexeme buffer + 1.
jsr malloc ; Make a new string.
- ldb.q ptr3 ; Get the address of the lexeme buffer.
- ldy.q idx1 ; Get the size of the lexeme buffer + 1.
- iny ;
+ lea s, (ptr3) ; Get the address of the lexeme buffer.
+ mov d, a ; Get the pointer of the new string.
jsr memcpy ; Copy the string in the lexeme buffer into the new string.
sta.q t_str ; Save it in the token string.
and #0 ; Reset A.
@@ -379,6 +350,9 @@ ptok_scol:
@end:
jsr make_tok ; Create the token.
rts ; End of parse_ptok.
+ptok_hash:
+ inc.w idx0 ;
+ rts ; End of parse_ptok.
ptok_dolr:
lda #TOK_HEX ; Set the lexeme type to TOK_HEX.
sta lex_type ;