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.
This commit is contained in:
2023-10-22 20:26:17 +01:00
parent 137a6d3b75
commit b20ad511a0
2 changed files with 25 additions and 0 deletions

View File

@@ -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})