aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-22 22:04:13 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-22 22:04:13 +0100
commitb44eaefabb6dc6825e959910dafcc99f3dc99256 (patch)
tree4192f2b48ecd89c04ec9bb8f0fd904c456954c7d
parent7243ac253398708c79ed3883fe83d31037b4ce93 (diff)
downloadovm-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).
-rw-r--r--src/inst.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/inst.c b/src/inst.c
index 23bf48f..72b2706 100644
--- a/src/inst.c
+++ b/src/inst.c
@@ -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)