show bytes in disassembly

This commit is contained in:
Jorj Bauer 2021-01-11 08:43:23 -05:00
parent 12d4f7bdf2
commit 579e7e9f79

View File

@ -133,6 +133,7 @@ uint8_t Disassembler::instructionToMnemonic(uint16_t addr, uint8_t *p, char *out
addrmode amode = opcodes[*p].mode;
uint16_t target = 0;
char arg[40] = "\0";
char bytes[10] = "\0";
switch (amode) {
case A_REL:
@ -153,14 +154,19 @@ uint8_t Disassembler::instructionToMnemonic(uint16_t addr, uint8_t *p, char *out
switch (instructionBytes(*p)) {
case 1:
// no arguments
sprintf(bytes, " %.2X ", *(uint8_t *)p);
break;
case 2:
sprintf(arg, "%s$%X%s", om.prefix, target, om.suffix);
sprintf(bytes, " %.2X %.2X ", *(uint8_t *)p, *(uint8_t *)(p+1));
break;
case 3:
sprintf(arg, "%s$%X%s", om.prefix, target, om.suffix);
sprintf(bytes, "%.2X %.2X %.2X ", *(uint8_t *)p, *(uint8_t *)(p+1), *(uint8_t *)(p+2));
break;
}
sprintf(outp, "$%.4X %s %s", addr, mn, arg);
sprintf(outp, "$%.4X %s %s %s", addr, bytes, mn, arg);
return instructionBytes(*p);
}