aboutsummaryrefslogtreecommitdiff
path: root/vm
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-29 16:58:18 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-29 16:58:18 +0000
commit597a45aa73d4d66fce4dd9135087e0e82f46899c (patch)
tree773f5afb7174d89e6e3eb01e08a79ffad040ea87 /vm
parentc4cb45f3ad3fedb4247577cffb3e5b07f41dab02 (diff)
downloadovm-597a45aa73d4d66fce4dd9135087e0e82f46899c.tar.gz
ovm-597a45aa73d4d66fce4dd9135087e0e82f46899c.tar.bz2
ovm-597a45aa73d4d66fce4dd9135087e0e82f46899c.zip
Fixed bug where JUMP_REGISTER couldn't be in bytecode read
Diffstat (limited to 'vm')
-rw-r--r--vm/inst.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/vm/inst.c b/vm/inst.c
index d553d57..1c245fa 100644
--- a/vm/inst.c
+++ b/vm/inst.c
@@ -323,14 +323,13 @@ inst_t inst_read_bytecode(darr_t *darr)
inst_t inst = {0};
opcode_t opcode = darr->data[darr->used++];
if (opcode > OP_HALT || opcode == NUMBER_OF_OPCODES || opcode < OP_NOOP)
- // Translate to NOOP
- return inst;
+ return INST_NOOP;
// Read operands
if (OPCODE_IS_TYPE(opcode, OP_PUSH))
inst.operand = read_type_from_darr(darr, (data_type_t)opcode);
// Read register (as a byte)
else if (OPCODE_IS_TYPE(opcode, OP_PUSH_REGISTER) ||
- OPCODE_IS_TYPE(opcode, OP_MOV) || inst.opcode == OP_JUMP_STACK)
+ OPCODE_IS_TYPE(opcode, OP_MOV) || opcode == OP_JUMP_REGISTER)
inst.operand = read_type_from_darr(darr, DATA_TYPE_BYTE);
else if (OPCODE_IS_TYPE(opcode, OP_DUP) || opcode == OP_JUMP_ABS ||
OPCODE_IS_TYPE(opcode, OP_JUMP_IF))