diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-02 23:25:33 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-02 23:25:33 +0000 |
commit | 4eee6e1a0a17465756f1b4156727c55bc17214f1 (patch) | |
tree | 818e3265163a6b07478817ab39782a688f94232b /vm/runtime.h | |
parent | 86977fe3c140e6b5d6c09bc1d26d9f97d89a6488 (diff) | |
download | ovm-4eee6e1a0a17465756f1b4156727c55bc17214f1.tar.gz ovm-4eee6e1a0a17465756f1b4156727c55bc17214f1.tar.bz2 ovm-4eee6e1a0a17465756f1b4156727c55bc17214f1.zip |
Implemented subroutine instructions in runtime
Very easy overall, printing the call stack not so much.
Diffstat (limited to 'vm/runtime.h')
-rw-r--r-- | vm/runtime.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/vm/runtime.h b/vm/runtime.h index ce3cb42..c98dfcf 100644 --- a/vm/runtime.h +++ b/vm/runtime.h @@ -24,6 +24,8 @@ typedef enum ERR_OK = 0, ERR_STACK_UNDERFLOW, ERR_STACK_OVERFLOW, + ERR_CALL_STACK_UNDERFLOW, + ERR_CALL_STACK_OVERFLOW, ERR_INVALID_OPCODE, ERR_INVALID_REGISTER_BYTE, ERR_INVALID_REGISTER_HWORD, @@ -46,14 +48,19 @@ typedef struct struct Stack { byte *data; - word ptr, max; + size_t ptr, max; } stack; heap_t heap; struct Program { inst_t *instructions; - word ptr, max; + size_t ptr, max; } program; + struct CallStack + { + word *address_pointers; + size_t ptr, max; + } call_stack; } vm_t; err_t vm_execute(vm_t *); @@ -63,6 +70,7 @@ void vm_load_stack(vm_t *, byte *, size_t); void vm_load_registers(vm_t *, registers_t); void vm_load_heap(vm_t *, heap_t); void vm_load_program(vm_t *, inst_t *, size_t); +void vm_load_call_stack(vm_t *, word *, size_t); void vm_stop(vm_t *); // Print routines @@ -71,6 +79,7 @@ void vm_print_registers(vm_t *, FILE *); void vm_print_stack(vm_t *, FILE *); void vm_print_program(vm_t *, FILE *); void vm_print_heap(vm_t *, FILE *); +void vm_print_call_stack(vm_t *, FILE *); void vm_print_all(vm_t *, FILE *); // Execution routines |