From a24a096e2a6fb8c48ae5a71673e82dccb627c2b9 Mon Sep 17 00:00:00 2001
From: Aryadev Chavali <aryadev@aryadevchavali.com>
Date: Mon, 16 Oct 2023 01:06:02 +0100
Subject: Made OP_HALT the only instruction to have the top byte filled

---
 src/inst.h | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

(limited to 'src')

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
 {
-- 
cgit v1.2.3-13-gbd6f