diff options
author | Oxore <oxore@protonmail.com> | 2023-08-12 21:03:57 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-08-12 21:18:23 +0300 |
commit | d30df7b755345fdffa8025511275a27b100c69d6 (patch) | |
tree | ecf18c32582219d8de224992e6320a74eb30b62c | |
parent | 3e584a3df6bede3ae545ae530c619ba6eecc97c9 (diff) |
Impl globl, align, text and file directive emission
-rw-r--r-- | main.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -19,7 +19,7 @@ #endif #ifndef TRACE_PARSER -#define TRACE_PARSER 1 +#define TRACE_PARSER 0 #endif #if defined(__GNUC__) || defined(__clang__) @@ -2947,6 +2947,22 @@ static void emit_arg( } } +static void emit_directive_same( + const struct lex *const lex, + const struct directive *const dir, + FILE *const s) +{ + const struct token name_token = lex->tokbuf[dir->name_token]; + fprintf(s, "\t%.*s", (int)name_token.length, lex->input + name_token.offset); + if (dir->num_tokens) { + fprintf(s, "\t"); + } + for (size_t i = 0; i < dir->num_tokens; i++) { + const struct token token = lex->tokbuf[dir->first_token + i]; + fprintf(s, "%.*s ", (int)token.length, lex->input + token.offset); + } +} + static int assem_emit(struct assem *const self, FILE *const stream) { const struct lex *const lex = self->pars->lex; @@ -2978,6 +2994,18 @@ static int assem_emit(struct assem *const self, FILE *const stream) emit_arg(lex, &instr.arg2, stream); } } + } else if (stmt->type == ST_DIRECTIVE) { + const struct directive *dir = &stmt->directive; + switch (dir->type) { + case DT_ALIGN: + case DT_FILE: + case DT_GLOBL: + case DT_TEXT: + emit_directive_same(lex, dir, stream); + break; + default: + break; + } } if (stmt->comment_token) { const struct token token = lex->tokbuf[stmt->comment_token]; |