aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-16 01:06:02 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-16 01:06:02 +0100
commita24a096e2a6fb8c48ae5a71673e82dccb627c2b9 (patch)
treee3a1cf2945b419247e08b18f489f75a7990e8197
parent0f37a5994046a06cf086b6ac4af62620c5881fc7 (diff)
downloadovm-a24a096e2a6fb8c48ae5a71673e82dccb627c2b9.tar.gz
ovm-a24a096e2a6fb8c48ae5a71673e82dccb627c2b9.tar.bz2
ovm-a24a096e2a6fb8c48ae5a71673e82dccb627c2b9.zip
Made OP_HALT the only instruction to have the top byte filled
-rw-r--r--src/inst.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/inst.h b/src/inst.h
index a520304..3c77a86 100644
--- a/src/inst.h
+++ b/src/inst.h
@@ -36,19 +36,20 @@ typedef enum
OP_MOV_WORD = 0b00011000,
OP_MOV_FLOAT = 0b00101000,
- OP_HALT,
+ OP_HALT = 0b10000000, // top of the byte is a HALT
} opcode_t;
// Masks and values to check if an opcode is of a type
typedef enum
{
- OP_TYPE_PUSH = 0b1,
- OP_TYPE_PUSH_REGISTER = 0b10,
- OP_TYPE_POP = 0b100,
- OP_TYPE_MOV = 0b1000,
+ OP_TYPE_PUSH = 0b00000001,
+ OP_TYPE_PUSH_REGISTER = 0b00000010,
+ OP_TYPE_POP = 0b00000100,
+ OP_TYPE_MOV = 0b00001000,
+ OP_TYPE_HALT = 0b10000000,
} opcode_type_t;
-#define OPCODE_IS_TYPE(OPCODE, TYPE) ((OPCODE & TYPE) == TYPE)
+#define OPCODE_IS_TYPE(OPCODE, OP_TYPE) (((OPCODE) & (OP_TYPE)) == (OP_TYPE))
typedef struct
{