From b20ad511a0a375da9dd92542e58a4a2cd0721d9f Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 22 Oct 2023 20:26:17 +0100 Subject: Added opcode OP_DUP_* Duplicates the nth datum off the stack, pushing it to the top. Useful for operations such as MOV which eat the stack. --- src/inst.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/inst.h') diff --git a/src/inst.h b/src/inst.h index 1073593..16374ee 100644 --- a/src/inst.h +++ b/src/inst.h @@ -40,6 +40,10 @@ typedef enum OP_MOV_HWORD, OP_MOV_WORD, + OP_DUP_BYTE, + OP_DUP_HWORD, + OP_DUP_WORD, + // Boolean operations OP_NOT_BYTE, OP_NOT_HWORD, @@ -108,6 +112,9 @@ inst_t *insts_read_bytecode_file(FILE *, size_t *); #define INST_PUSH_REG(TYPE, REG) \ ((inst_t){.opcode = OP_PUSH_REGISTER_##TYPE, .operand = D##TYPE(REG)}) +#define INST_DUP(TYPE, OP) \ + ((inst_t){.opcode = OP_DUP_##TYPE, .operand = DWORD(OP)}) + #define INST_NOT(TYPE) ((inst_t){.opcode = OP_NOT_##TYPE}) #define INST_OR(TYPE) ((inst_t){.opcode = OP_OR_##TYPE}) #define INST_AND(TYPE) ((inst_t){.opcode = OP_AND_##TYPE}) -- cgit v1.2.3-13-gbd6f