diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 21:47:19 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 21:47:19 +0000 |
commit | 44125d7ad9fedbe693136969bf4a11d8c33bcab1 (patch) | |
tree | 14fa7e21e1562d41418fbb8dabaeda78d862d22e | |
parent | ea715c569eba9cc8310e15ce2e3ded9723a5e8c1 (diff) | |
download | ovm-44125d7ad9fedbe693136969bf4a11d8c33bcab1.tar.gz ovm-44125d7ad9fedbe693136969bf4a11d8c33bcab1.tar.bz2 ovm-44125d7ad9fedbe693136969bf4a11d8c33bcab1.zip |
Implemented OP_MSIZE into lexer/parser of ASM
-rw-r--r-- | asm/lexer.c | 9 | ||||
-rw-r--r-- | asm/lexer.h | 1 | ||||
-rw-r--r-- | asm/parser.c | 3 |
3 files changed, 12 insertions, 1 deletions
diff --git a/asm/lexer.c b/asm/lexer.c index ca467c5..4e92502 100644 --- a/asm/lexer.c +++ b/asm/lexer.c @@ -50,6 +50,8 @@ const char *token_type_as_cstr(token_type_t type) return "MGET"; case TOKEN_MDELETE: return "MDELETE"; + case TOKEN_MSIZE: + return "MSIZE"; case TOKEN_NOT: return "NOT"; case TOKEN_OR: @@ -125,7 +127,7 @@ bool is_valid_hex_char(char c) token_t tokenise_symbol(buffer_t *buffer, size_t *column) { - static_assert(NUMBER_OF_OPCODES == 83, "tokenise_buffer: Out of date!"); + static_assert(NUMBER_OF_OPCODES == 84, "tokenise_buffer: Out of date!"); size_t sym_size = 0; for (; sym_size < space_left(buffer) && @@ -196,6 +198,11 @@ token_t tokenise_symbol(buffer_t *buffer, size_t *column) offset = 7; type = TOKEN_MDELETE; } + else if (sym_size >= 5 && strncmp(opcode, "MSIZE", 5) == 0) + { + offset = 5; + type = TOKEN_MSIZE; + } else if (sym_size >= 3 && strncmp(opcode, "NOT", 3) == 0) { offset = 3; diff --git a/asm/lexer.h b/asm/lexer.h index c7d1f3d..000e33a 100644 --- a/asm/lexer.h +++ b/asm/lexer.h @@ -30,6 +30,7 @@ typedef enum TokenType TOKEN_MSET, TOKEN_MGET, TOKEN_MDELETE, + TOKEN_MSIZE, TOKEN_NOT, TOKEN_OR, TOKEN_AND, diff --git a/asm/parser.c b/asm/parser.c index a7340f9..73cd7be 100644 --- a/asm/parser.c +++ b/asm/parser.c @@ -233,6 +233,9 @@ perr_t parse_next_inst(token_stream_t *stream, inst_t *ret) case TOKEN_MDELETE: ret->opcode = OP_MDELETE; break; + case TOKEN_MSIZE: + ret->opcode = OP_MSIZE; + break; case TOKEN_NOT: ret->opcode = OP_NOT_BYTE; return parse_utype_inst(stream, ret); |