diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-02 23:29:23 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-02 23:29:23 +0000 |
commit | 6c4469958e9373773eb7c43d98ff5e20b062c153 (patch) | |
tree | bf36f3848031fe2a879aa19048920253bfc06bf9 /asm/lexer.c | |
parent | bd39c2b2835974c4ad9313f49a273df1af5887af (diff) | |
download | ovm-6c4469958e9373773eb7c43d98ff5e20b062c153.tar.gz ovm-6c4469958e9373773eb7c43d98ff5e20b062c153.tar.bz2 ovm-6c4469958e9373773eb7c43d98ff5e20b062c153.zip |
Implemented CALL(_STACK) and RET on the assembler
Diffstat (limited to 'asm/lexer.c')
-rw-r--r-- | asm/lexer.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/asm/lexer.c b/asm/lexer.c index baa5e92..525deb2 100644 --- a/asm/lexer.c +++ b/asm/lexer.c @@ -92,6 +92,12 @@ const char *token_type_as_cstr(token_type_t type) return "JUMP_STACK"; case TOKEN_JUMP_IF: return "JUMP_IF"; + case TOKEN_CALL: + return "CALL"; + case TOKEN_CALL_STACK: + return "CALL_STACK"; + case TOKEN_RET: + return "RET"; case TOKEN_SYMBOL: return "SYMBOL"; } @@ -139,7 +145,7 @@ bool is_valid_hex_char(char c) token_t tokenise_symbol(buffer_t *buffer, size_t *column) { - static_assert(NUMBER_OF_OPCODES == 95, "tokenise_buffer: Out of date!"); + static_assert(NUMBER_OF_OPCODES == 98, "tokenise_buffer: Out of date!"); size_t sym_size = 0; for (; sym_size < space_left(buffer) && @@ -310,6 +316,21 @@ token_t tokenise_symbol(buffer_t *buffer, size_t *column) offset = 8; type = TOKEN_JUMP_IF; } + else if (sym_size == 10 && strncmp(opcode, "CALL.STACK", 10) == 0) + { + offset = 10; + type = TOKEN_CALL_STACK; + } + else if (sym_size == 4 && strncmp(opcode, "CALL", 4) == 0) + { + offset = 4; + type = TOKEN_CALL; + } + else if (sym_size == 3 && strncmp(opcode, "RET", 3) == 0) + { + offset = 3; + type = TOKEN_RET; + } else is_opcode = false; |