From c17680035780e4ac13631126c8f448765e55b3fa Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Wed, 31 May 2023 20:41:10 +0200 Subject: [PATCH] pop moves value into the register at arg1 cool --- src/instructions.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/instructions.c b/src/instructions.c index 50e73d1..2183742 100644 --- a/src/instructions.c +++ b/src/instructions.c @@ -198,12 +198,17 @@ void push() { } void pop() { + if (!is_reg(args->arg1)) { + last_check_args_code = ARG1_WRONG; + return; + } + if (top == -1) { //stack underflow last_stack_code = UNDERFLOW; return; } - --top; + *get_reg(args->arg1) = stack[top--]; } void and() {