aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-15 21:02:40 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-15 21:03:27 +0100
commit56c545e7c9b9074a5c5e621b57c87e9e6556978b (patch)
treea01dc44bfbc6fa8902dd8f83fd6c029844a9f6a9 /src
parent33aa62634af2bddb64b678c065aa597756feb14d (diff)
downloadovm-56c545e7c9b9074a5c5e621b57c87e9e6556978b.tar.gz
ovm-56c545e7c9b9074a5c5e621b57c87e9e6556978b.tar.bz2
ovm-56c545e7c9b9074a5c5e621b57c87e9e6556978b.zip
Added opcodes for MOV and ability for instructions to hold registers
Pretty simple implementation
Diffstat (limited to 'src')
-rw-r--r--src/inst.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/inst.h b/src/inst.h
index 086696a..8649599 100644
--- a/src/inst.h
+++ b/src/inst.h
@@ -23,15 +23,21 @@ typedef enum
OP_PUSH_WORD = 0b0101,
OP_PUSH_FLOAT = 0b1001,
+ OP_MOV_BYTE = 0b0010,
+ OP_MOV_WORD = 0b0110,
+ OP_MOV_FLOAT = 0b1010,
+
OP_HALT,
} opcode_t;
-#define OPCODE_IS_PUSH(OPCODE) (((OPCODE)&1) == 1)
+#define OPCODE_IS_PUSH(OPCODE) (((OPCODE)&0b1) == 0b1)
+#define OPCODE_IS_MOV(OPCODE) (((OPCODE)&0b10) == 0b10)
typedef struct
{
opcode_t opcode;
data_t operand;
+ word reg;
} inst_t;
#define INST_BPUSH(BYTE) \
@@ -43,4 +49,13 @@ typedef struct
#define INST_FPUSH(FLOAT) \
((inst_t){.opcode = OP_PUSH_FLOAT, .operand = DFLOAT(FLOAT)})
+#define INST_BMOV(BYTE, REG) \
+ ((inst_t){.opcode = OP_MOV_BYTE, .operand = DBYTE(BYTE), .reg = (REG)})
+
+#define INST_WMOV(WORD, REG) \
+ ((inst_t){.opcode = OP_MOV_WORD, .operand = DWORD(WORD), .reg = (REG)})
+
+#define INST_FMOV(FLOAT, REG) \
+ ((inst_t){.opcode = OP_MOV_FLOAT, .operand = DFLOAT(FLOAT), .reg = (REG)})
+
#endif