- if (opcode != 0)
- {
- if (a == 0x1e || a == 0x1f) {
- printf(" %04x", d->ram[addr + instr_len]);
- instr_len++;
+/* dcpu16_disassemble_print
+ print the words of the instruction at addr, followed by its assembly representation
+ returns the length of the instruction in words
+ */
+DCPU16_WORD dcpu16_disassemble_print(struct dcpu16 *d, DCPU16_WORD addr) {
+ DCPU16_WORD opcode, a, b, instr_len, i;
+ const struct opcode_entry *e;
+ unsigned int indent = 0;
+ unsigned int partial = 0;
+
+ if (!d) return 0;
+
+ /*
+ Check the previous instruction, to see if this one should be
+ indented. This check isn't foolproof, as preceeding addresses
+ could be data which happen to match instructions..
+ */
+ for (i = 3; i; i--) {
+ instruction_decode_(d, addr - i, &opcode, &a, &b, &instr_len);
+ if (instr_len > i)
+ partial++;
+ if (instr_len == i && opcode >= 0xc) {
+ indent++;
+ break;