Added instructions for popping differing types

Bit mask is 100.
This commit is contained in:
2023-10-15 21:09:00 +01:00
parent 2bc20f07d3
commit 00517fddd6

View File

@@ -19,19 +19,22 @@ typedef enum
{
OP_NOOP = 0,
OP_PUSH_BYTE = 0b0001,
OP_PUSH_WORD = 0b0101,
OP_PUSH_FLOAT = 0b1001,
OP_MOV_BYTE = 0b0010,
OP_MOV_WORD = 0b0110,
OP_MOV_FLOAT = 0b1010,
OP_PUSH_BYTE = 0b00000001,
OP_PUSH_WORD = 0b00000101,
OP_PUSH_FLOAT = 0b00001001,
OP_MOV_BYTE = 0b00000010,
OP_MOV_WORD = 0b00000110,
OP_MOV_FLOAT = 0b00001010,
OP_POP_BYTE = 0b00000100,
OP_POP_WORD = 0b00001100,
OP_POP_FLOAT = 0b00010100,
OP_HALT,
} opcode_t;
#define OPCODE_IS_PUSH(OPCODE) (((OPCODE)&0b1) == 0b1)
#define OPCODE_IS_MOV(OPCODE) (((OPCODE)&0b10) == 0b10)
#define OPCODE_IS_POP(OPCODE) (((OPCODE)&0b100) == 0b100)
typedef struct
{
@@ -58,4 +61,13 @@ typedef struct
#define INST_FMOV(FLOAT, REG) \
((inst_t){.opcode = OP_MOV_FLOAT, .operand = DFLOAT(FLOAT), .reg = (REG)})
#define INST_BPOP(BYTE) \
((inst_t){.opcode = OP_POP_BYTE, .operand = DBYTE(BYTE)})
#define INST_WPOP(WORD) \
((inst_t){.opcode = OP_POP_WORD, .operand = DWORD(WORD)})
#define INST_FPOP(FLOAT) \
((inst_t){.opcode = OP_POP_FLOAT, .operand = DFLOAT(FLOAT)})
#endif