diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-16 01:06:49 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-16 01:18:05 +0100 |
commit | 6038363d2facd5c8a79d9c4920ca5b3cf70bef95 (patch) | |
tree | b848954978e0706c64e0755a0a4e723af2c170c8 /src/inst.h | |
parent | a24a096e2a6fb8c48ae5a71673e82dccb627c2b9 (diff) | |
download | ovm-6038363d2facd5c8a79d9c4920ca5b3cf70bef95.tar.gz ovm-6038363d2facd5c8a79d9c4920ca5b3cf70bef95.tar.bz2 ovm-6038363d2facd5c8a79d9c4920ca5b3cf70bef95.zip |
Added functionality to read and write instruction bytecode
Uses some bit hacks to quickly check what data type an opcode may have
by shifting down to units then casting it to a data_type_t.
Not very well tested yet, we'll need to see now.
Diffstat (limited to 'src/inst.h')
-rw-r--r-- | src/inst.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -13,7 +13,10 @@ #ifndef INST_H #define INST_H +#include <stdlib.h> + #include "./base.h" +#include "./darr.h" typedef enum { @@ -57,6 +60,13 @@ typedef struct data_t operand; } inst_t; +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 +// darr.available is the number of overall bytes and used is the +// cursor (where we are in the buffer). +inst_t inst_read_bytecode(darr_t *); + #define INST_BPUSH(BYTE) \ ((inst_t){.opcode = OP_PUSH_BYTE, .operand = DBYTE(BYTE)}) |