diff options
-rw-r--r-- | asm/lexer.c | 16 | ||||
-rw-r--r-- | asm/lexer.h | 2 | ||||
-rw-r--r-- | asm/parser.c | 6 |
3 files changed, 23 insertions, 1 deletions
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; diff --git a/asm/lexer.h b/asm/lexer.h index 000e33a..e8897b6 100644 --- a/asm/lexer.h +++ b/asm/lexer.h @@ -28,7 +28,9 @@ typedef enum TokenType TOKEN_DUP, TOKEN_MALLOC, TOKEN_MSET, + TOKEN_MSET_STACK, TOKEN_MGET, + TOKEN_MGET_STACK, TOKEN_MDELETE, TOKEN_MSIZE, TOKEN_NOT, diff --git a/asm/parser.c b/asm/parser.c index 73cd7be..4b5eee1 100644 --- a/asm/parser.c +++ b/asm/parser.c @@ -230,6 +230,12 @@ perr_t parse_next_inst(token_stream_t *stream, inst_t *ret) case TOKEN_MGET: ret->opcode = OP_MGET_BYTE; return parse_utype_inst_with_operand(stream, ret); + case TOKEN_MSET_STACK: + ret->opcode = OP_MSET_STACK_BYTE; + return parse_utype_inst(stream, ret); + case TOKEN_MGET_STACK: + ret->opcode = OP_MGET_STACK_BYTE; + return parse_utype_inst(stream, ret); case TOKEN_MDELETE: ret->opcode = OP_MDELETE; break; |