diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-22 22:04:13 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-22 22:04:13 +0100 |
commit | b44eaefabb6dc6825e959910dafcc99f3dc99256 (patch) | |
tree | 4192f2b48ecd89c04ec9bb8f0fd904c456954c7d /src | |
parent | 7243ac253398708c79ed3883fe83d31037b4ce93 (diff) | |
download | ovm-b44eaefabb6dc6825e959910dafcc99f3dc99256.tar.gz ovm-b44eaefabb6dc6825e959910dafcc99f3dc99256.tar.bz2 ovm-b44eaefabb6dc6825e959910dafcc99f3dc99256.zip |
Remove get_opcode_data_type
Was only used for OP_PUSH data types anyway, so is essentially
useless. Only OP_PUSH has operands after it that directly relate to
it: the rest either have a fixed type (a byte for registers, for
example) or NIL (because they have no operand).
Diffstat (limited to 'src')
-rw-r--r-- | src/inst.c | 18 |
1 files changed, 2 insertions, 16 deletions
@@ -184,27 +184,13 @@ word convert_bytes_to_word(byte *bytes) return w; } -data_type_t get_opcode_data_type(opcode_t opcode) -{ - data_type_t type = DATA_TYPE_NIL; - if (OPCODE_IS_TYPE(opcode, OP_PUSH)) - type = (data_type_t)opcode; - else if (OPCODE_IS_TYPE(opcode, OP_PUSH_REGISTER)) - type = opcode >> 1; - else if (OPCODE_IS_TYPE(opcode, OP_POP)) - type = opcode >> 2; - else if (OPCODE_IS_TYPE(opcode, OP_MOV)) - type = opcode >> 3; - return type; -} - void inst_print(inst_t instruction, FILE *fp) { static_assert(NUMBER_OF_OPCODES == 37, "inst_bytecode_size: Out of date"); fprintf(fp, "%s(", opcode_as_cstr(instruction.opcode)); if (OPCODE_IS_TYPE(instruction.opcode, OP_PUSH)) { - data_type_t type = get_opcode_data_type(instruction.opcode); + data_type_t type = (data_type_t)instruction.opcode; fprintf(fp, "datum=0x"); data_print(instruction.operand, type, fp); } @@ -337,7 +323,7 @@ inst_t inst_read_bytecode(darr_t *darr) return inst; // Read operands if (OPCODE_IS_TYPE(opcode, OP_PUSH)) - inst.operand = read_type_from_darr(darr, get_opcode_data_type(opcode)); + 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) |