From 00517fddd68c3d46ad09bebe2c3ac38e791576f7 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 15 Oct 2023 21:09:00 +0100 Subject: Added instructions for popping differing types Bit mask is 100. --- src/inst.h | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/inst.h b/src/inst.h index 8649599..d27f7d3 100644 --- a/src/inst.h +++ b/src/inst.h @@ -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 -- cgit v1.2.3-13-gbd6f