aboutsummaryrefslogtreecommitdiff
path: root/src/program.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/program.c')
-rw-r--r--src/program.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/program.c b/src/program.c
index 6c5ac7b..31485ca 100644
--- a/src/program.c
+++ b/src/program.c
@@ -605,7 +605,7 @@ static CHECK_RESULT int amal_program_read_instructions(amal_program *self, amal_
self->return_value_index = 0;
/* func_offset will only be non-zero when the function has been decoded (FUNC_START) */
- if(func_def.func_offset != 0) {
+ if(func_def.func_offset != ~(u32)0UL) {
/* TODO: Instead of pushing num args, push the sum of sizeof the last num_args */
return_if_error(amal_exec_call(executor, func_def.func_offset, dst_reg));
} else {
@@ -633,7 +633,12 @@ static CHECK_RESULT int amal_program_read_instructions(amal_program *self, amal_
break;
}
case AMAL_OP_CALLR: {
- assert(bool_false && "TODO: Implement CALLR");
+ AmalReg dst_reg;
+ AmalReg func_ptr_reg = self->data.data[self->read_index];
+ assert(self->return_value_index == 1);
+ dst_reg = self->return_values_stack[0];
+ self->return_value_index = 0;
+ return_if_error(amal_exec_callr(executor, func_ptr_reg, dst_reg));
self->read_index += 1;
break;
}