diff --git a/lib/inst.c b/lib/inst.c index 3c1eb4a..6198387 100644 --- a/lib/inst.c +++ b/lib/inst.c @@ -382,7 +382,7 @@ int inst_read_bytecode(inst_t *ptr, byte_t *bytes, size_t size_bytes) static_assert(NUMBER_OF_OPCODES == 99, "inst_read_bytecode: Out of date"); opcode_t opcode = *(bytes++); - if (opcode > OP_HALT || opcode < OP_NOOP) + if (opcode >= NUMBER_OF_OPCODES || opcode < OP_NOOP) return READ_ERR_INVALID_OPCODE; inst_t inst = {opcode, {0}}; diff --git a/lib/inst.h b/lib/inst.h index 6f14830..6b7cbfe 100644 --- a/lib/inst.h +++ b/lib/inst.h @@ -28,6 +28,7 @@ typedef enum { OP_NOOP = 0, + OP_HALT, // Dealing with data and registers OP_PUSH_BYTE, @@ -161,7 +162,6 @@ typedef enum OP_CALL_STACK, OP_RET, - OP_HALT, // Should not be an opcode NUMBER_OF_OPCODES, } opcode_t;