diff options
Diffstat (limited to 'src/as_op.c')
| -rw-r--r-- | src/as_op.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/as_op.c b/src/as_op.c index 8b5d887..67c91ff 100644 --- a/src/as_op.c +++ b/src/as_op.c @@ -92,6 +92,46 @@ struct op_table_entry op_table [] = { {OP_END, NULL}, }; +int op_size(enum op op) { + if (op == OP_IMM) { + return 8 + 1; + } + if (op == OP_CALL + || op == OP_JMP + || op == OP_JNZ + || op == OP_JZ + || op == OP_SYSCALL) { + return 8 + 1 + 1; + } + if (op == OP_LDARG || op == OP_STARG) { + return 9 + 9 + 1 + 9 + 4; + } + if (op == OP_LDVAR || op == OP_STVAR) { + return 9 + 9 + 2 + 9 + 4; + } + return 1; +} + +int is_ld_op(enum op op) { + if (op == OP_LD + || op == OP_LD8 + || op == OP_LD16 + || op == OP_LD32) { + return 1; + } + return 0; +} + +int is_st_op(enum op op) { + if (op == OP_ST + || op == OP_ST8 + || op == OP_ST16 + || op == OP_ST32) { + return 1; + } + return 0; +} + enum op str2op(const char* str) { for (int i = 0; op_table[i].name != NULL; i++) { if (strcmp(op_table[i].name, str) == 0) { |
