From 6c4469958e9373773eb7c43d98ff5e20b062c153 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 2 Nov 2023 23:29:23 +0000 Subject: Implemented CALL(_STACK) and RET on the assembler --- asm/parser.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'asm/parser.c') 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)) -- cgit v1.2.3-13-gbd6f