diff options
| -rw-r--r-- | main.c | 44 | 
1 files changed, 41 insertions, 3 deletions
| @@ -3022,10 +3022,13 @@ static void emit_directive_same(      }      for (size_t i = 0; i < dir->num_tokens; i++) {          const struct token token = lex->tokbuf[dir->first_token + i]; +        if (i != 0) { +            fprintf(s, " "); +        }          if (token.type == TT_ID) {              emit_token_id(lex, &token, s);          } else { -            fprintf(s, "%.*s ", (int)token.length, lex->input + token.offset); +            fprintf(s, "%.*s", (int)token.length, lex->input + token.offset);          }      }  } @@ -3046,7 +3049,38 @@ static void emit_directive_byte(      }      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); +        if (i != 0) { +            fprintf(s, " "); +        } +        if (token.type == TT_ID) { +            emit_token_id(lex, &token, s); +            fprintf(s, " "); +        } else { +            fprintf(s, "%.*s", (int)token.length, lex->input + token.offset); +        } +    } +} + +static void emit_directive_short( +        const struct lex *const lex, +        const struct directive *const dir, +        FILE *const s) +{ +    if (dir->num_tokens < 1) { +        // We won't emit this because it is invalid +        return; +    } +    fprintf(s, "\t.short\t"); +    for (size_t i = 0; i < dir->num_tokens; i++) { +        const struct token token = lex->tokbuf[dir->first_token + i]; +        if (i != 0) { +            fprintf(s, " "); +        } +        if (token.type == TT_ID) { +            emit_token_id(lex, &token, s); +        } else { +            fprintf(s, "%.*s", (int)token.length, lex->input + token.offset); +        }      }  } @@ -3096,7 +3130,7 @@ static int assem_emit(struct assem *const self, FILE *const stream)                  fprintf(stream, ".%c", opsize_to_char(opsize));              }              if (instr.arg1.type != ARG_NONE) { -                fprintf(stream, " "); +                fprintf(stream, "\t");                  emit_arg(lex, &instr.arg1, stream);                  if (instr.arg2.type != ARG_NONE) {                      fprintf(stream, ", "); @@ -3116,6 +3150,10 @@ static int assem_emit(struct assem *const self, FILE *const stream)              case DT_BYTE:                  emit_directive_byte(lex, dir, stream);                  break; +            case DT_SHORT: +            case DT_WORD: +                emit_directive_short(lex, dir, stream); +                break;              default:                  break;              } | 
