diff options
-rw-r--r-- | lib/inst.c | 20 | ||||
-rw-r--r-- | lib/inst.h | 17 |
2 files changed, 31 insertions, 6 deletions
@@ -65,12 +65,24 @@ const char *opcode_as_cstr(opcode_t code) return "MSET_HWORD"; case OP_MSET_WORD: return "MSET_WORD"; + case OP_MSET_STACK_BYTE: + return "MSET_STACK_BYTE"; + case OP_MSET_STACK_HWORD: + return "MSET_STACK_HWORD"; + case OP_MSET_STACK_WORD: + return "MSET_STACK_WORD"; case OP_MGET_BYTE: return "MGET_BYTE"; case OP_MGET_HWORD: return "MGET_HWORD"; case OP_MGET_WORD: return "MGET_WORD"; + case OP_MGET_STACK_BYTE: + return "MGET_STACK_BYTE"; + case OP_MGET_STACK_HWORD: + return "MGET_STACK_HWORD"; + case OP_MGET_STACK_WORD: + return "MGET_STACK_WORD"; case OP_MDELETE: return "MDELETE"; case OP_MSIZE: @@ -217,7 +229,7 @@ void data_print(data_t datum, data_type_t type, FILE *fp) void inst_print(inst_t instruction, FILE *fp) { - static_assert(NUMBER_OF_OPCODES == 84, "inst_bytecode_size: Out of date"); + static_assert(NUMBER_OF_OPCODES == 90, "inst_bytecode_size: Out of date"); fprintf(fp, "%s(", opcode_as_cstr(instruction.opcode)); if (OPCODE_IS_TYPE(instruction.opcode, OP_PUSH)) { @@ -250,7 +262,7 @@ void inst_print(inst_t instruction, FILE *fp) size_t inst_bytecode_size(inst_t inst) { - static_assert(NUMBER_OF_OPCODES == 84, "inst_bytecode_size: Out of date"); + static_assert(NUMBER_OF_OPCODES == 90, "inst_bytecode_size: Out of date"); size_t size = 1; // for opcode if (OPCODE_IS_TYPE(inst.opcode, OP_PUSH)) { @@ -275,7 +287,7 @@ size_t inst_bytecode_size(inst_t inst) void inst_write_bytecode(inst_t inst, darr_t *darr) { - static_assert(NUMBER_OF_OPCODES == 84, "inst_write_bytecode: Out of date"); + static_assert(NUMBER_OF_OPCODES == 90, "inst_write_bytecode: Out of date"); // Append opcode darr_append_byte(darr, inst.opcode); // Then append 0 or more operands @@ -351,7 +363,7 @@ data_t read_type_from_darr(darr_t *darr, data_type_t type) inst_t inst_read_bytecode(darr_t *darr) { - static_assert(NUMBER_OF_OPCODES == 84, "inst_read_bytecode: Out of date"); + static_assert(NUMBER_OF_OPCODES == 90, "inst_read_bytecode: Out of date"); if (darr->used >= darr->available) return (inst_t){0}; inst_t inst = {0}; @@ -48,12 +48,23 @@ typedef enum OP_MALLOC_BYTE, OP_MALLOC_HWORD, OP_MALLOC_WORD, + OP_MSET_BYTE, OP_MSET_HWORD, OP_MSET_WORD, + + OP_MSET_STACK_BYTE, + OP_MSET_STACK_HWORD, + OP_MSET_STACK_WORD, + OP_MGET_BYTE, OP_MGET_HWORD, OP_MGET_WORD, + + OP_MGET_STACK_BYTE, + OP_MGET_STACK_HWORD, + OP_MGET_STACK_WORD, + OP_MDELETE, OP_MSIZE, @@ -187,10 +198,12 @@ inst_t *insts_read_bytecode_file(FILE *, size_t *); ((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_MSET_STACK(TYPE) ((inst_t){.opcode = OP_MSET_STACK_##TYPE}) #define INST_MGET(TYPE, OP) \ ((inst_t){.opcode = OP_MGET_##TYPE, .operand = DWORD(OP)}) -#define INST_MDELETE ((inst_t){.opcode = OP_MDELETE}) -#define INST_MSIZE ((inst_t){.opcode = OP_MSIZE}) +#define INST_MGET_STACK(TYPE) ((inst_t){.opcode = OP_MGET_STACK_##TYPE}) +#define INST_MDELETE ((inst_t){.opcode = OP_MDELETE}) +#define INST_MSIZE ((inst_t){.opcode = OP_MSIZE}) #define INST_NOT(TYPE) ((inst_t){.opcode = OP_NOT_##TYPE}) #define INST_OR(TYPE) ((inst_t){.opcode = OP_OR_##TYPE}) |