From 35a18609864470b3dc49f3a9a6cb6ec93e57300d Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 25 Feb 2021 12:43:11 -0500 Subject: - 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. --- programs/sub-suite/lexer.s | 48 +++++++++++----------------------------------- 1 file changed, 11 insertions(+), 37 deletions(-) (limited to 'programs/sub-suite/lexer.s') 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 ; -- cgit v1.2.3-13-gbd6f