diff options
-rw-r--r-- | main.c | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -2839,6 +2839,32 @@ static void pars_destroy(struct pars *const self) free(self->symbuf); } +static bool is_bcc(const enum mnemonic mnemonic) +{ + switch (mnemonic) { + case MN_BRA: + case MN_BSR: + case MN_BCC: + case MN_BCS: + case MN_BEQ: + case MN_BGE: + case MN_BGT: + case MN_BHI: + case MN_BLE: + case MN_BLS: + case MN_BLT: + case MN_BMI: + case MN_BNE: + case MN_BPL: + case MN_BVC: + case MN_BVS: + return true; + default: + break; + } + return false; +} + static int assem_init(struct assem *const self, const struct pars *const pars) { *self = (struct assem){ @@ -3022,6 +3048,17 @@ static void emit_directive_byte( } } +static enum opsize assem_resolve_bcc( + struct assem *const self, + const size_t stmt_number) +{ + const struct pars *const pars = self->pars; + (void) pars; + (void) stmt_number; + // TODO impl real resolving + return OPSIZE_S; +} + static int assem_emit(struct assem *const self, FILE *const stream) { const struct lex *const lex = self->pars->lex; @@ -3052,6 +3089,9 @@ static int assem_emit(struct assem *const self, FILE *const stream) fprintf(stream, "\t%s", mnemonic_to_string(instr.mnemonic)); if (instr.opsize != OPSIZE_NONE) { fprintf(stream, ".%c", opsize_to_char(instr.opsize)); + } else if (is_bcc(instr.mnemonic)) { + enum opsize opsize = assem_resolve_bcc(self, i); + fprintf(stream, ".%c", opsize_to_char(opsize)); } if (instr.arg1.type != ARG_NONE) { fprintf(stream, " "); |