};
static const char *opcode_io_flags[] = {
- "memory I/O",
- "hardware I/O",
"self-modifying code",
"no invalidation",
+ "no mask",
+};
+
+static const char *opcode_io_modes[] = {
+ "Memory access",
+ "I/O access",
+ "RAM access",
+ "BIOS access",
+ "Scratchpad access",
};
static const char *opcode_branch_flags[] = {
};
static int print_flags(char *buf, size_t len, u16 flags,
- const char **array, size_t array_size)
+ const char **array, size_t array_size,
+ bool is_io)
{
- const char *flag_name;
- unsigned int i;
+ const char *flag_name, *io_mode_name;
+ unsigned int i, io_mode;
size_t count = 0, bytes;
bool first = true;
count += bytes;
}
+ if (is_io) {
+ io_mode = LIGHTREC_FLAGS_GET_IO_MODE(flags);
+ if (io_mode > 0) {
+ io_mode_name = opcode_io_modes[io_mode - 1];
+
+ if (first)
+ bytes = snprintf(buf, len, "(%s", io_mode_name);
+ else
+ bytes = snprintf(buf, len, ", %s", io_mode_name);
+
+ first = false;
+ buf += bytes;
+ len -= bytes;
+ count += bytes;
+ }
+ }
+
if (!first)
count += snprintf(buf, len, ")");
else
}
static int print_op(union code c, u32 pc, char *buf, size_t len,
- const char ***flags_ptr, size_t *nb_flags)
+ const char ***flags_ptr, size_t *nb_flags,
+ bool *is_io)
{
if (c.opcode == 0)
return snprintf(buf, len, "nop ");
case OP_SWR:
*flags_ptr = opcode_io_flags;
*nb_flags = ARRAY_SIZE(opcode_io_flags);
+ *is_io = true;
return snprintf(buf, len, "%s%s,%hd(%s)",
std_opcodes[c.i.op],
lightrec_reg_name(c.i.rt),
}
}
-void lightrec_print_disassembly(const struct block *block, const u32 *code)
+void lightrec_print_disassembly(const struct block *block, const u32 *code_ptr)
{
const struct opcode *op;
const char **flags_ptr;
size_t nb_flags, count, count2;
char buf[256], buf2[256], buf3[256];
unsigned int i;
- u32 pc, branch_pc;
+ u32 pc, branch_pc, code;
+ bool is_io;
for (i = 0; i < block->nb_ops; i++) {
op = &block->opcode_list[i];
branch_pc = get_branch_pc(block, i, 0);
pc = block->pc + (i << 2);
+ code = LE32TOH(code_ptr[i]);
- count = print_op((union code)code[i], pc, buf, sizeof(buf),
- &flags_ptr, &nb_flags);
+ count = print_op((union code)code, pc, buf, sizeof(buf),
+ &flags_ptr, &nb_flags, &is_io);
flags_ptr = NULL;
nb_flags = 0;
+ is_io = false;
count2 = print_op(op->c, branch_pc, buf2, sizeof(buf2),
- &flags_ptr, &nb_flags);
+ &flags_ptr, &nb_flags, &is_io);
- if (code[i] == op->c.opcode) {
+ if (code == op->c.opcode) {
*buf2 = '\0';
count2 = 0;
}
- print_flags(buf3, sizeof(buf3), op->flags, flags_ptr, nb_flags);
+ print_flags(buf3, sizeof(buf3), op->flags, flags_ptr, nb_flags,
+ is_io);
printf("0x%08x (0x%x)\t%s%*c%s%*c%s\n", pc, i << 2,
buf, 30 - (int)count, ' ', buf2, 30 - (int)count2, ' ', buf3);