From 693ec7a9d0f408eba12a2020eb7bdf78c2db7573 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 1 Nov 2023 17:54:15 +0000 Subject: Changed inst bytecode methods for new register system As registers may be theoretically infinite in number, we should use the largest size possible when referring to them in bytecode (a word). --- lib/inst.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/inst.c b/lib/inst.c index 98bbc98..9a7fac8 100644 --- a/lib/inst.c +++ b/lib/inst.c @@ -324,9 +324,8 @@ void inst_write_bytecode(inst_t inst, darr_t *darr) to_append = (data_type_t)inst.opcode; else if (OPCODE_IS_TYPE(inst.opcode, OP_PUSH_REGISTER) || OPCODE_IS_TYPE(inst.opcode, OP_MOV) || - inst.opcode == OP_JUMP_REGISTER) - to_append = DATA_TYPE_BYTE; - else if (OPCODE_IS_TYPE(inst.opcode, OP_DUP) || inst.opcode == OP_JUMP_ABS || + inst.opcode == OP_JUMP_REGISTER || inst.opcode == OP_JUMP_ABS || + OPCODE_IS_TYPE(inst.opcode, OP_DUP) || OPCODE_IS_TYPE(inst.opcode, OP_JUMP_IF)) to_append = DATA_TYPE_WORD; @@ -401,9 +400,8 @@ inst_t inst_read_bytecode(darr_t *darr) 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) || 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_MOV) || opcode == OP_JUMP_REGISTER || + opcode == OP_JUMP_ABS || OPCODE_IS_TYPE(opcode, OP_DUP) || OPCODE_IS_TYPE(opcode, OP_JUMP_IF)) inst.operand = read_type_from_darr(darr, DATA_TYPE_WORD); // Otherwise opcode doesn't take operands -- cgit v1.2.3-13-gbd6f