diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 17:54:15 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 17:54:15 +0000 |
commit | 693ec7a9d0f408eba12a2020eb7bdf78c2db7573 (patch) | |
tree | f2f469b0aab76f891582271ff6270fdab70d2c3d | |
parent | 081661cb6b0c2932a1e7e1d16860942fa7f9f195 (diff) | |
download | ovm-693ec7a9d0f408eba12a2020eb7bdf78c2db7573.tar.gz ovm-693ec7a9d0f408eba12a2020eb7bdf78c2db7573.tar.bz2 ovm-693ec7a9d0f408eba12a2020eb7bdf78c2db7573.zip |
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).
-rw-r--r-- | lib/inst.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -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 |