aboutsummaryrefslogtreecommitdiff
path: root/src/base.h
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-16 01:06:49 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-16 01:18:05 +0100
commit6038363d2facd5c8a79d9c4920ca5b3cf70bef95 (patch)
treeb848954978e0706c64e0755a0a4e723af2c170c8 /src/base.h
parenta24a096e2a6fb8c48ae5a71673e82dccb627c2b9 (diff)
downloadovm-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/base.h')
-rw-r--r--src/base.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/base.h b/src/base.h
index 0e822d5..670aa81 100644
--- a/src/base.h
+++ b/src/base.h
@@ -35,6 +35,14 @@ typedef union
f64 as_float;
} data_t;
+typedef enum
+{
+ DATA_TYPE_NIL = 0,
+ DATA_TYPE_BYTE = 1,
+ DATA_TYPE_WORD = 3,
+ DATA_TYPE_FLOAT = 5,
+} data_type_t;
+
#define DBYTE(BYTE) ((data_t){.as_byte = (BYTE)})
#define DWORD(WORD) ((data_t){.as_word = (WORD)})
#define DFLOAT(FLOAT) ((data_t){.as_float = (FLOAT)})