From 696589b7b6179e9955c8c9892af7a4fa1ab14075 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sat, 21 Oct 2023 23:42:07 +0100 Subject: Introduced opcodes for NOT, OR, AND, XOR and EQ Does a bit level version of each of these. --- src/inst.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/inst.h') 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 -- cgit v1.2.3-13-gbd6f