aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-21 23:42:07 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-21 23:42:07 +0100
commit696589b7b6179e9955c8c9892af7a4fa1ab14075 (patch)
tree0a70c694aafe05b39a5f142e11280aa81f9545c6 /src
parentf9b2c8ed777148739eae4ef050eb66b02cddbd51 (diff)
downloadovm-696589b7b6179e9955c8c9892af7a4fa1ab14075.tar.gz
ovm-696589b7b6179e9955c8c9892af7a4fa1ab14075.tar.bz2
ovm-696589b7b6179e9955c8c9892af7a4fa1ab14075.zip
Introduced opcodes for NOT, OR, AND, XOR and EQ
Does a bit level version of each of these.
Diffstat (limited to 'src')
-rw-r--r--src/inst.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/inst.h b/src/inst.h
index 805822b..df4e2e1 100644
--- a/src/inst.h
+++ b/src/inst.h
@@ -40,6 +40,27 @@ typedef enum
OP_MOV_HWORD,
OP_MOV_WORD,
+ // Boolean operations
+ OP_NOT_BYTE,
+ OP_NOT_HWORD,
+ OP_NOT_WORD,
+
+ OP_OR_BYTE,
+ OP_OR_HWORD,
+ OP_OR_WORD,
+
+ OP_AND_BYTE,
+ OP_AND_HWORD,
+ OP_AND_WORD,
+
+ OP_XOR_BYTE,
+ OP_XOR_HWORD,
+ OP_XOR_WORD,
+
+ OP_EQ_BYTE,
+ OP_EQ_HWORD,
+ OP_EQ_WORD,
+
OP_HALT = 0b11111111, // top of the byte is a HALT
} opcode_t;
@@ -79,4 +100,10 @@ inst_t *insts_read_bytecode_file(FILE *, size_t *);
#define INST_PUSH_REG(TYPE, REG) \
((inst_t){.opcode = OP_PUSH_REGISTER_##TYPE, .operand = D##TYPE(REG)})
+#define INST_NOT(TYPE) ((inst_t){.opcode = OP_NOT_##TYPE})
+#define INST_OR(TYPE) ((inst_t){.opcode = OP_OR_##TYPE})
+#define INST_AND(TYPE) ((inst_t){.opcode = OP_AND_##TYPE})
+#define INST_XOR(TYPE) ((inst_t){.opcode = OP_XOR_##TYPE})
+#define INST_EQ(TYPE) ((inst_t){.opcode = OP_EQ_##TYPE})
+
#endif