diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-22 20:26:17 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-22 20:26:17 +0100 |
commit | b20ad511a0a375da9dd92542e58a4a2cd0721d9f (patch) | |
tree | 353d7c44262732169837a8e792357d506fe3ef23 /src/inst.h | |
parent | 137a6d3b759d30665ef0e375226c928956f119f1 (diff) | |
download | ovm-b20ad511a0a375da9dd92542e58a4a2cd0721d9f.tar.gz ovm-b20ad511a0a375da9dd92542e58a4a2cd0721d9f.tar.bz2 ovm-b20ad511a0a375da9dd92542e58a4a2cd0721d9f.zip |
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.
Diffstat (limited to 'src/inst.h')
-rw-r--r-- | src/inst.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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}) |