diff options
Diffstat (limited to 'lib/inst.c')
-rw-r--r-- | lib/inst.c | 94 |
1 files changed, 6 insertions, 88 deletions
@@ -23,258 +23,176 @@ const char *opcode_as_cstr(opcode_t code) { case OP_NOOP: return "NOOP"; - break; case OP_PUSH_BYTE: return "PUSH_BYTE"; - break; case OP_PUSH_WORD: return "PUSH_WORD"; - break; case OP_PUSH_HWORD: return "PUSH_HWORD"; - break; case OP_PUSH_REGISTER_BYTE: return "PUSH_REGISTER_BYTE"; - break; case OP_PUSH_REGISTER_WORD: return "PUSH_REGISTER_WORD"; - break; case OP_PUSH_REGISTER_HWORD: return "PUSH_REGISTER_HWORD"; - break; case OP_POP_BYTE: return "POP_BYTE"; - break; case OP_POP_WORD: return "POP_WORD"; - break; case OP_POP_HWORD: return "POP_HWORD"; - break; case OP_MOV_BYTE: return "MOV_BYTE"; - break; case OP_MOV_WORD: return "MOV_WORD"; - break; case OP_MOV_HWORD: return "MOV_HWORD"; - break; case OP_DUP_BYTE: return "DUP_BYTE"; - break; case OP_DUP_HWORD: return "DUP_HWORD"; - break; case OP_DUP_WORD: return "DUP_WORD"; - break; case OP_MALLOC_BYTE: return "MALLOC_BYTE"; - break; case OP_MALLOC_HWORD: return "MALLOC_HWORD"; - break; case OP_MALLOC_WORD: return "MALLOC_WORD"; - break; case OP_MSET_BYTE: return "MSET_BYTE"; - break; case OP_MSET_HWORD: return "MSET_HWORD"; - break; case OP_MSET_WORD: return "MSET_WORD"; - break; case OP_MGET_BYTE: return "MGET_BYTE"; - break; case OP_MGET_HWORD: return "MGET_HWORD"; - break; case OP_MGET_WORD: return "MGET_WORD"; - break; case OP_MDELETE: return "MDELETE"; - break; + case OP_MSIZE: + return "MDELETE"; case OP_NOT_BYTE: return "NOT_BYTE"; - break; case OP_NOT_HWORD: return "NOT_HWORD"; - break; case OP_NOT_WORD: return "NOT_WORD"; - break; case OP_OR_BYTE: return "OR_BYTE"; - break; case OP_OR_HWORD: return "OR_HWORD"; - break; case OP_OR_WORD: return "OR_WORD"; - break; case OP_AND_BYTE: return "AND_BYTE"; - break; case OP_AND_HWORD: return "AND_HWORD"; - break; case OP_AND_WORD: return "AND_WORD"; - break; case OP_XOR_BYTE: return "XOR_BYTE"; - break; case OP_XOR_HWORD: return "XOR_HWORD"; - break; case OP_XOR_WORD: return "XOR_WORD"; - break; case OP_EQ_BYTE: return "EQ_BYTE"; - break; case OP_EQ_HWORD: return "EQ_HWORD"; - break; case OP_EQ_WORD: return "EQ_WORD"; - break; case OP_LT_BYTE: return "LT_BYTE"; - break; case OP_LT_CHAR: return "LT_CHAR"; - break; case OP_LT_HWORD: return "LT_HWORD"; - break; case OP_LT_INT: return "LT_INT"; - break; case OP_LT_LONG: return "LT_LONG"; - break; case OP_LT_WORD: return "LT_WORD"; - break; case OP_LTE_BYTE: return "LTE_BYTE"; - break; case OP_LTE_CHAR: return "LTE_CHAR"; - break; case OP_LTE_HWORD: return "LTE_HWORD"; - break; case OP_LTE_INT: return "LTE_INT"; - break; case OP_LTE_LONG: return "LTE_LONG"; - break; case OP_LTE_WORD: return "LTE_WORD"; - break; case OP_GT_BYTE: return "GT_BYTE"; - break; case OP_GT_CHAR: return "GT_CHAR"; - break; case OP_GT_HWORD: return "GT_HWORD"; - break; case OP_GT_INT: return "GT_INT"; - break; case OP_GT_LONG: return "GT_LONG"; - break; case OP_GT_WORD: return "GT_WORD"; - break; case OP_GTE_BYTE: return "GTE_BYTE"; - break; case OP_GTE_CHAR: return "GTE_CHAR"; - break; case OP_GTE_HWORD: return "GTE_HWORD"; - break; case OP_GTE_INT: return "GTE_INT"; - break; case OP_GTE_LONG: return "GTE_LONG"; - break; case OP_GTE_WORD: return "GTE_WORD"; - break; case OP_PLUS_BYTE: return "PLUS_BYTE"; - break; case OP_PLUS_HWORD: return "PLUS_HWORD"; - break; case OP_PLUS_WORD: return "PLUS_WORD"; case OP_MULT_BYTE: return "MULT_BYTE"; - break; case OP_MULT_HWORD: return "MULT_HWORD"; - break; case OP_MULT_WORD: return "MULT_WORD"; - break; case OP_JUMP_ABS: return "JUMP_ABS"; - break; case OP_JUMP_STACK: return "JUMP_STACK"; - break; case OP_JUMP_REGISTER: return "JUMP_REGISTER"; - break; case OP_JUMP_IF_BYTE: return "JUMP_IF_BYTE"; - break; case OP_JUMP_IF_HWORD: return "JUMP_IF_HWORD"; - break; case OP_JUMP_IF_WORD: return "JUMP_IF_WORD"; - break; case OP_PRINT_CHAR: return "PRINT_CHAR"; - break; case OP_PRINT_BYTE: return "PRINT_BYTE"; - break; case OP_PRINT_INT: return "PRINT_INT"; - break; case OP_PRINT_HWORD: return "PRINT_HWORD"; - break; case OP_PRINT_LONG: return "PRINT_LONG"; - break; case OP_PRINT_WORD: return "PRINT_WORD"; - break; case OP_HALT: return "HALT"; - break; case NUMBER_OF_OPCODES: return ""; - break; } return ""; } @@ -299,7 +217,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 == 83, "inst_bytecode_size: Out of date"); + static_assert(NUMBER_OF_OPCODES == 84, "inst_bytecode_size: Out of date"); fprintf(fp, "%s(", opcode_as_cstr(instruction.opcode)); if (OPCODE_IS_TYPE(instruction.opcode, OP_PUSH)) { @@ -332,7 +250,7 @@ void inst_print(inst_t instruction, FILE *fp) size_t inst_bytecode_size(inst_t inst) { - static_assert(NUMBER_OF_OPCODES == 83, "inst_bytecode_size: Out of date"); + static_assert(NUMBER_OF_OPCODES == 84, "inst_bytecode_size: Out of date"); size_t size = 1; // for opcode if (OPCODE_IS_TYPE(inst.opcode, OP_PUSH)) { @@ -357,7 +275,7 @@ size_t inst_bytecode_size(inst_t inst) void inst_write_bytecode(inst_t inst, darr_t *darr) { - static_assert(NUMBER_OF_OPCODES == 83, "inst_write_bytecode: Out of date"); + static_assert(NUMBER_OF_OPCODES == 84, "inst_write_bytecode: Out of date"); // Append opcode darr_append_byte(darr, inst.opcode); // Then append 0 or more operands @@ -433,7 +351,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 == 83, "inst_read_bytecode: Out of date"); + static_assert(NUMBER_OF_OPCODES == 84, "inst_read_bytecode: Out of date"); if (darr->used >= darr->available) return (inst_t){0}; inst_t inst = {0}; |