aboutsummaryrefslogtreecommitdiff
path: root/src/inst.h
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-16 12:45:04 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-16 12:55:15 +0100
commit44f8c81efeabb4576be427e7d53e982848cb5be9 (patch)
treec11e8b1e7675bc8ea5173380816b08128e184f8e /src/inst.h
parentd01b39d1bb08687077309eb00704461c228c6a3e (diff)
downloadovm-44f8c81efeabb4576be427e7d53e982848cb5be9.tar.gz
ovm-44f8c81efeabb4576be427e7d53e982848cb5be9.tar.bz2
ovm-44f8c81efeabb4576be427e7d53e982848cb5be9.zip
Added opcode_as_cstr, opcode_type_as_cstr and inst_print
Pretty self explanatory, helps with logging.
Diffstat (limited to 'src/inst.h')
-rw-r--r--src/inst.h7
1 files changed, 7 insertions, 0 deletions
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 <stdio.h>
#include <stdlib.h>
#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