Commit bb9cfd7c authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

midgard: Flesh out disassembly for extended branch

parent 196c9c93
......@@ -488,6 +488,29 @@ static void print_scalar_field(const char *name, uint16_t* words, uint16_t reg_w
printf("\n");
}
static void print_branch_op(int op)
{
switch (op)
{
case midgard_jmp_writeout_op_branch_cond: printf("cond."); break;
case midgard_jmp_writeout_op_writeout: printf("write."); break;
case midgard_jmp_writeout_op_discard: printf("discard."); break;
default: break;
}
}
static void print_branch_cond(int cond)
{
switch (cond)
{
case 0: printf("write0"); break;
case 1: printf("false"); break;
case 2: printf("true"); break;
case 3: printf("write"); break;
default: break;
}
}
static void print_compact_branch_writeout_field(uint16_t word)
{
midgard_jmp_writeout_op op = word & 0x7;
......@@ -515,22 +538,9 @@ static void print_compact_branch_writeout_field(uint16_t word)
printf("br.");
switch (op)
{
case midgard_jmp_writeout_op_branch_cond: printf("cond."); break;
case midgard_jmp_writeout_op_writeout: printf("write."); break;
case midgard_jmp_writeout_op_discard: printf("discard."); break;
default: break;
}
switch (br_cond.cond)
{
case 0: printf("unk0"); break;
case 1: printf("false"); break;
case 2: printf("true"); break;
case 3: printf("write"); break;
default: break;
}
print_branch_op(br_cond.op);
print_branch_cond(br_cond.cond);
printf(" ");
if (br_cond.offset >= 0)
printf("+");
......@@ -556,8 +566,23 @@ static void print_extended_branch_writeout_field(uint64_t _word)
midgard_branch_extended br;
memcpy((char*) &br, (char*) &word, sizeof(br));
printf("%d, %d, %d, %d, %X\n", br.dest_tag, br.unknown, br.offset, br.zero, br.cond);
printf("%X\n", word);
printf("br.");
print_branch_op(br.op);
print_branch_cond(br.cond);
/* XXX: This can't be right */
if (br.unknown)
printf(".unknown%d\n", br.unknown);
if (br.zero)
printf(".zero%d\n", br.zero);
printf(" ");
if (br.offset >= 0)
printf("+");
printf("%d\n", br.offset);
break;
}
default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment