From 90e04542a284f642b0a3a56ed568b5d5828bc376 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 1 Nov 2023 22:09:39 +0000 Subject: Implemented stack versions of MGET and MSET in assembler --- asm/lexer.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'asm/lexer.c') diff --git a/asm/lexer.c b/asm/lexer.c index 4e92502..dfc4976 100644 --- a/asm/lexer.c +++ b/asm/lexer.c @@ -46,8 +46,12 @@ const char *token_type_as_cstr(token_type_t type) return "MALLOC"; case TOKEN_MSET: return "MSET"; + case TOKEN_MSET_STACK: + return "MSET_STACK"; case TOKEN_MGET: return "MGET"; + case TOKEN_MGET_STACK: + return "MGET_STACK"; case TOKEN_MDELETE: return "MDELETE"; case TOKEN_MSIZE: @@ -127,7 +131,7 @@ bool is_valid_hex_char(char c) token_t tokenise_symbol(buffer_t *buffer, size_t *column) { - static_assert(NUMBER_OF_OPCODES == 84, "tokenise_buffer: Out of date!"); + static_assert(NUMBER_OF_OPCODES == 90, "tokenise_buffer: Out of date!"); size_t sym_size = 0; for (; sym_size < space_left(buffer) && @@ -183,11 +187,21 @@ token_t tokenise_symbol(buffer_t *buffer, size_t *column) offset = 6; type = TOKEN_MALLOC; } + else if (sym_size >= 10 && strncmp(opcode, "MSET.STACK", 10) == 0) + { + offset = 10; + type = TOKEN_MSET_STACK; + } else if (sym_size >= 4 && strncmp(opcode, "MSET", 4) == 0) { offset = 4; type = TOKEN_MSET; } + else if (sym_size >= 10 && strncmp(opcode, "MGET.STACK", 10) == 0) + { + offset = 10; + type = TOKEN_MGET_STACK; + } else if (sym_size >= 4 && strncmp(opcode, "MGET", 4) == 0) { offset = 4; -- cgit v1.2.3-13-gbd6f