Provide disasm -e to show technical explanation in comment

This commit is contained in:
Stefan Rueger
2024-07-22 23:39:33 +01:00
parent 0c3044217b
commit 4526d330ea
3 changed files with 10 additions and 1 deletions

View File

@@ -848,6 +848,8 @@ static void disassemble(const char *buf, int addr, int opcode, AVR_opcode mnemo,
}
if(cx->dis_opts.show_name)
add_comment(line, avr_opcodes[mnemo].description);
if(cx->dis_opts.show_explanation)
add_comment(line, avr_opcodes[mnemo].operation);
// Trim trailing spaces
while(--c >= line->code && *c == ' ')
*c = 0;
@@ -934,7 +936,7 @@ int disasm(const char *buf, int buflen, int addr, int leadin, int leadout) {
if(!*line.comment || !cx->dis_opts.show_comments)
term_out("%s\n", line.code);
else
term_out("%-30s ; %s\n", line.code, line.comment);
term_out("%-27s ; %s\n", line.code, line.comment);
if(mnemo == OPCODE_ret || mnemo == OPCODE_u_ret || mnemo == OPCODE_ret || mnemo == OPCODE_u_ret)
term_out("\n");

View File

@@ -1462,6 +1462,7 @@ typedef struct {
int show_flags;
int show_cycles;
int show_name;
int show_explanation;
int avrgcc_style;
int process_labels;
int avrlevel;

View File

@@ -220,6 +220,7 @@ static int disasm_ison(char c) {
case 'f': return !!cx->dis_opts.show_flags;
case 'q': return !!cx->dis_opts.show_cycles;
case 'n': return !!cx->dis_opts.show_name;
case 'e': return !!cx->dis_opts.show_explanation;
case 's': return !!cx->dis_opts.avrgcc_style;
case 'l': return !!cx->dis_opts.process_labels;
case 'd': return cx->dis_opts.avrlevel == (PART_ALL | OP_AVR_ILL);
@@ -267,6 +268,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc,
{{'f', 'F'}, {"show affected flags in SREG", "don't show SREG flags"}},
{{'q', 'Q'}, {"show cycles", "don't show cycles"}},
{{'n', 'N'}, {"put opcode full name into comment", "don't show full name"}},
{{'e', 'E'}, {"put explanation into comment", "don't show explanation"}},
{{'s', 'S'}, {"use avr-gcc code style", "use AVR instruction set style"}},
{{'l', 'L'}, {"preprocess jump/call labels", "don't preprocess labels"}},
{{'d', 'D'}, {"decode all opcodes", "decode only opcodes for the part"}},
@@ -484,6 +486,7 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c
cx->dis_opts.show_flags = 0;
cx->dis_opts.show_cycles = 0;
cx->dis_opts.show_name = 0;
cx->dis_opts.show_explanation = 0;
cx->dis_opts.avrgcc_style = 1;
cx->dis_opts.process_labels = 1;
cx->dis_opts.tagfile = NULL;
@@ -521,6 +524,9 @@ static int cmd_disasm(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c
case 'n': case 'N':
cx->dis_opts.show_name = !!islower(chr);
break;
case 'e': case 'E':
cx->dis_opts.show_explanation = !!islower(chr);
break;
case 's': case 'S':
cx->dis_opts.avrgcc_style = !!islower(chr);
break;