diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 21:15:13 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 21:38:52 +0000 |
commit | eda49755bc91e03092dc1619d78cded126998d64 (patch) | |
tree | b04b40ca8ece612b116be902071069d140c32084 /lib/inst.h | |
parent | 4e64f1fe235ffaed6f2eb6fdb228b480c4dfcb1b (diff) | |
download | ovm-eda49755bc91e03092dc1619d78cded126998d64.tar.gz ovm-eda49755bc91e03092dc1619d78cded126998d64.tar.bz2 ovm-eda49755bc91e03092dc1619d78cded126998d64.zip |
Added instructions for allocating, setting, getting and deleting heap memory
One may allocate any number of (bytes|hwords|words), set or get some
index from allocated memory, and delete heap memory.
The idea is that all the relevant datums will be on the stack, so no
register usage. This means no instructions should use register space
at all (other than POP, which I'm debating about currently). Register
space is purely for users.
Diffstat (limited to 'lib/inst.h')
-rw-r--r-- | lib/inst.h | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -44,6 +44,18 @@ typedef enum OP_DUP_HWORD, OP_DUP_WORD, + // Dealing with the heap + OP_MALLOC_BYTE, + OP_MALLOC_HWORD, + OP_MALLOC_WORD, + OP_MSET_BYTE, + OP_MSET_HWORD, + OP_MSET_WORD, + OP_MGET_BYTE, + OP_MGET_HWORD, + OP_MGET_WORD, + OP_MDELETE, + // Boolean operations OP_NOT_BYTE, OP_NOT_HWORD, @@ -170,6 +182,14 @@ inst_t *insts_read_bytecode_file(FILE *, size_t *); #define INST_DUP(TYPE, OP) \ ((inst_t){.opcode = OP_DUP_##TYPE, .operand = DWORD(OP)}) +#define INST_MALLOC(TYPE, OP) \ + ((inst_t){.opcode = OP_MALLOC_##TYPE, .operand = DWORD(OP)}) +#define INST_MSET(TYPE, OP) \ + ((inst_t){.opcode = OP_MSET_##TYPE, .operand = DWORD(OP)}) +#define INST_MGET(TYPE, OP) \ + ((inst_t){.opcode = OP_MGET_##TYPE, .operand = DWORD(OP)}) +#define INST_MDELETE ((inst_t){.opcode = OP_MDELETE}) + #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}) |