From 44f8c81efeabb4576be427e7d53e982848cb5be9 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 16 Oct 2023 12:45:04 +0100 Subject: Added opcode_as_cstr, opcode_type_as_cstr and inst_print Pretty self explanatory, helps with logging. --- src/inst.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/inst.h') diff --git a/src/inst.h b/src/inst.h index e5c6146..2748c7f 100644 --- a/src/inst.h +++ b/src/inst.h @@ -13,6 +13,7 @@ #ifndef INST_H #define INST_H +#include #include #include "./base.h" @@ -42,6 +43,8 @@ typedef enum OP_HALT = 0b10000000, // top of the byte is a HALT } opcode_t; +const char *opcode_as_cstr(opcode_t); + // Masks and values to check if an opcode is of a type typedef enum { @@ -52,6 +55,8 @@ typedef enum OP_TYPE_HALT = 0b10000000, } opcode_type_t; +const char *opcode_type_as_cstr(opcode_type_t); + #define OPCODE_IS_TYPE(OPCODE, OP_TYPE) (((OPCODE) & (OP_TYPE)) == (OP_TYPE)) typedef struct @@ -60,6 +65,8 @@ typedef struct data_t operand; } inst_t; +void inst_print(inst_t, FILE *); + size_t inst_bytecode_size(inst_t); void inst_write_bytecode(inst_t, darr_t *); // Here the dynamic array is a preloaded buffer of bytes, where -- cgit v1.2.3-13-gbd6f