[qfcc] Dump emitted statements when verbosity >= 2

I wish I had done this years (decades, even!) ago. It makes checking the
output so much easier.
This commit is contained in:
Bill Currie 2022-01-20 12:55:56 +09:00
parent a4ebd6aa58
commit 19baae6969
3 changed files with 17 additions and 0 deletions

View file

@ -40,5 +40,6 @@ pr_ushort_t opcode_get (instruction_t *inst) __attribute__((pure));
instruction_t *opcode_find (const char *name, struct operand_s *op_a,
struct operand_s *op_b, struct operand_s *op_c);
void opcode_init (void);
void opcode_print_statement (pr_uint_t addr, dstatement_t *st);
#endif//__opcodes_h

View file

@ -217,6 +217,10 @@ emit_statement (statement_t *statement)
s->b = def_b ? def_b->offset : 0;
s->c = def_c ? def_c->offset : 0;
if (options.verbosity >= 2) {
opcode_print_statement (pr.code->size - 1, s);
}
add_statement_def_ref (def_a, s, 0);
add_statement_def_ref (def_b, s, 1);
add_statement_def_ref (def_c, s, 2);

View file

@ -351,3 +351,15 @@ opcode_init (void)
rua_opcode_init ();
}
}
void
opcode_print_statement (pr_uint_t addr, dstatement_t *st)
{
const char *mnemonic;
if (options.code.progsversion < PROG_VERSION) {
mnemonic = v6p_opcode_map[st->op].opname;
} else {
mnemonic = pr_opcodes[st->op].mnemonic;
}
printf ("%04x %8s %04x %04x %04x\n", addr, mnemonic, st->a, st->b, st->c);
}