aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-22 20:40:42 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-22 20:54:04 +0100
commitfffad9aea3594c7de6ba918058c1e033c725a274 (patch)
treee52f626d31fde264cb578af854c84cf697d36f1c /src/runtime.c
parentbc0e0fce252630110d6b0d18e55aac129b3d6d35 (diff)
downloadovm-fffad9aea3594c7de6ba918058c1e033c725a274.tar.gz
ovm-fffad9aea3594c7de6ba918058c1e033c725a274.tar.bz2
ovm-fffad9aea3594c7de6ba918058c1e033c725a274.zip
Added and implemented OP_JUMP_ABS
Jumps to the operand given, interpreted as a word, an absolute address.
Diffstat (limited to 'src/runtime.c')
-rw-r--r--src/runtime.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/runtime.c b/src/runtime.c
index c2c793c..5b6c547 100644
--- a/src/runtime.c
+++ b/src/runtime.c
@@ -19,7 +19,7 @@
void vm_execute(vm_t *vm)
{
- static_assert(NUMBER_OF_OPCODES == 31, "vm_execute: Out of date");
+ static_assert(NUMBER_OF_OPCODES == 32, "vm_execute: Out of date");
struct Program *prog = &vm->program;
if (prog->ptr >= prog->max)
// TODO: Error (Went past end of program)
@@ -110,6 +110,11 @@ void vm_execute(vm_t *vm)
vm_peek(vm, OPCODE_DATA_TYPE(instruction.opcode, OP_EQ)).as_word;
prog->ptr++;
}
+ else if (instruction.opcode == OP_JUMP_ABS)
+ {
+ // Set prog->ptr to the jump point requested
+ prog->ptr = instruction.operand.as_word;
+ }
else if (instruction.opcode == OP_HALT)
{
// Do nothing here. Should be caught by callers of vm_execute