aboutsummaryrefslogtreecommitdiff
path: root/asm/parser.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-02 23:29:23 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-02 23:29:23 +0000
commit6c4469958e9373773eb7c43d98ff5e20b062c153 (patch)
treebf36f3848031fe2a879aa19048920253bfc06bf9 /asm/parser.c
parentbd39c2b2835974c4ad9313f49a273df1af5887af (diff)
downloadovm-6c4469958e9373773eb7c43d98ff5e20b062c153.tar.gz
ovm-6c4469958e9373773eb7c43d98ff5e20b062c153.tar.bz2
ovm-6c4469958e9373773eb7c43d98ff5e20b062c153.zip
Implemented CALL(_STACK) and RET on the assembler
Diffstat (limited to 'asm/parser.c')
-rw-r--r--asm/parser.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/asm/parser.c b/asm/parser.c
index 4f76fe5..cf2e53e 100644
--- a/asm/parser.c
+++ b/asm/parser.c
@@ -418,6 +418,19 @@ perr_t parse_next(token_stream_t *stream, presult_t *ret)
*ret = (presult_t){.instruction = INST_JUMP_IF(BYTE, 0)};
return parse_jump_inst_operand(stream, ret);
}
+ case TOKEN_CALL:
+ *ret = (presult_t){.instruction = INST_CALL(0)};
+ ++stream->used;
+ if (stream->used >= stream->available)
+ return PERR_EXPECTED_OPERAND;
+ return parse_word_label_or_relative(stream, ret);
+ case TOKEN_CALL_STACK:
+ *ret = (presult_t){.instruction = INST_CALL_STACK,
+ .type = PRES_COMPLETE_RESULT};
+ break;
+ case TOKEN_RET:
+ *ret = (presult_t){.instruction = INST_RET, .type = PRES_COMPLETE_RESULT};
+ break;
case TOKEN_SYMBOL: {
size_t label_size = strcspn(token.str, ":");
if (label_size == strlen(token.str))