summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-08-12 22:20:25 +0300
committerOxore <oxore@protonmail.com>2023-08-12 22:42:06 +0300
commit3d92d620d11b50d8e54ebe1be1bc90416d723475 (patch)
treee232a162917dad2fa0b9065c0f2f2386b30c953f
parent11e8e014e6c0efb0e4d92c85b99ec675a3b292f5 (diff)
Impl stub of Bcc resolving
-rw-r--r--main.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/main.c b/main.c
index 3150da4..e6d13f4 100644
--- a/main.c
+++ b/main.c
@@ -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, " ");