diff options
author | Oxore <oxore@protonmail.com> | 2023-08-12 21:27:15 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-08-12 21:27:15 +0300 |
commit | 8a3b78c2332719084fcf18e58be357af1f1399fb (patch) | |
tree | cc02bb9b94b2350b1e9d0480a90de0b3afbda5b0 | |
parent | d30df7b755345fdffa8025511275a27b100c69d6 (diff) |
Impl opsize of mnemonic emission
-rw-r--r-- | main.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -1360,6 +1360,19 @@ static const char *opsize_to_string(const enum opsize s) return "_unknown"; } +static char opsize_to_char(const enum opsize s) +{ + switch (s) { + case OPSIZE_NONE: return '_'; + case OPSIZE_S: return 's'; + case OPSIZE_B: return 'b'; + case OPSIZE_W: return 'w'; + case OPSIZE_L: return 'l'; + } + UNREACHABLE(); + return '?'; +} + static enum mnemonic get_mnemonic_from_identifier( const char *const str, const size_t str_length) { @@ -2986,6 +2999,9 @@ static int assem_emit(struct assem *const self, FILE *const stream) if (stmt->type == ST_INSTRUCTION) { const struct instruction instr = stmt->instruction; fprintf(stream, "\t%s", mnemonic_to_string(instr.mnemonic)); + if (instr.opsize != OPSIZE_NONE) { + fprintf(stream, ".%c", opsize_to_char(instr.opsize)); + } if (instr.arg1.type != ARG_NONE) { fprintf(stream, " "); emit_arg(lex, &instr.arg1, stream); |