This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[patch] AVR Disasm
- From: "Svein E. Seldal" <Svein dot Seldal at solidas dot com>
- To: binutils at sources dot redhat dot com
- Date: Fri, 26 Nov 2004 19:49:12 +0100
- Subject: [patch] AVR Disasm
Hello
This patch will add printing of the symbols on the AVR's disassembly output.
While being a maintainer for another target, I guess I need
maintainer/community approval to check this into the CVS. Permission to check
in please?
2004-11-26 Svein E. Seldal <Svein.Seldal@solidas.com>
* avr-dis.c: Prettyprint. Added printing of symbol names in all
memory references
Regards,
Svein Seldal
? build.avr
? build.native
? gas/doc/as.info
Index: opcodes/avr-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/avr-dis.c,v
retrieving revision 1.10
diff -c -3 -p -r1.10 avr-dis.c
*** opcodes/avr-dis.c 18 Nov 2002 16:54:08 -0000 1.10
--- opcodes/avr-dis.c 26 Nov 2004 18:43:03 -0000
*************** const struct avr_opcodes_s avr_opcodes[]
*** 43,52 ****
};
static int avr_operand PARAMS ((unsigned int, unsigned int,
! unsigned int, int, char *, char *, int));
static int
! avr_operand (insn, insn2, pc, constraint, buf, comment, regs)
unsigned int insn;
unsigned int insn2;
unsigned int pc;
--- 43,52 ----
};
static int avr_operand PARAMS ((unsigned int, unsigned int,
! unsigned int, int, char *, char *, int, int *, bfd_vma *));
static int
! avr_operand (insn, insn2, pc, constraint, buf, comment, regs, sym, sym_addr)
unsigned int insn;
unsigned int insn2;
unsigned int pc;
*************** avr_operand (insn, insn2, pc, constraint
*** 54,61 ****
--- 54,64 ----
char *buf;
char *comment;
int regs;
+ int *sym;
+ bfd_vma *sym_addr;
{
int ok = 1;
+ *sym = 0;
switch (constraint)
{
*************** avr_operand (insn, insn2, pc, constraint
*** 145,159 ****
break;
case 'h':
! sprintf (buf, "0x%x",
! ((((insn & 1) | ((insn & 0x1f0) >> 3)) << 16) | insn2) * 2);
break;
case 'L':
{
int rel_addr = (((insn & 0xfff) ^ 0x800) - 0x800) * 2;
sprintf (buf, ".%+-8d", rel_addr);
! sprintf (comment, "0x%x", pc + 2 + rel_addr);
}
break;
--- 148,165 ----
break;
case 'h':
! *sym = 1;
! *sym_addr = ((((insn & 1) | ((insn & 0x1f0) >> 3)) << 16) | insn2) * 2;
! sprintf (buf, "0x");
break;
case 'L':
{
int rel_addr = (((insn & 0xfff) ^ 0x800) - 0x800) * 2;
sprintf (buf, ".%+-8d", rel_addr);
! *sym = 1;
! *sym_addr = pc + 2 + rel_addr;
! sprintf (comment, "0x");
}
break;
*************** avr_operand (insn, insn2, pc, constraint
*** 161,167 ****
{
int rel_addr = ((((insn >> 3) & 0x7f) ^ 0x40) - 0x40) * 2;
sprintf (buf, ".%+-8d", rel_addr);
! sprintf (comment, "0x%x", pc + 2 + rel_addr);
}
break;
--- 167,175 ----
{
int rel_addr = ((((insn >> 3) & 0x7f) ^ 0x40) - 0x40) * 2;
sprintf (buf, ".%+-8d", rel_addr);
! *sym = 1;
! *sym_addr = pc + 2 + rel_addr;
! sprintf (comment, "0x");
}
break;
*************** print_insn_avr(addr, info)
*** 265,270 ****
--- 273,280 ----
int cmd_len = 2;
int ok = 0;
char op1[20], op2[20], comment1[40], comment2[40];
+ int sym_op1 = 0, sym_op2 = 0;
+ bfd_vma sym_addr1, sym_addr2;
if (!initialized)
{
*************** print_insn_avr(addr, info)
*** 336,346 ****
{
int regs = REGISTER_P (*op);
! ok = avr_operand (insn, insn2, addr, *op, op1, comment1, 0);
if (ok && *(++op) == ',')
ok = avr_operand (insn, insn2, addr, *(++op), op2,
! *comment1 ? comment2 : comment1, regs);
}
}
--- 346,356 ----
{
int regs = REGISTER_P (*op);
! ok = avr_operand (insn, insn2, addr, *op, op1, comment1, 0, &sym_op1, &sym_addr1);
if (ok && *(++op) == ',')
ok = avr_operand (insn, insn2, addr, *(++op), op2,
! *comment1 ? comment2 : comment1, regs, &sym_op2, &sym_addr2);
}
}
*************** print_insn_avr(addr, info)
*** 356,362 ****
(*prin) (stream, "%s", ok ? opcode->name : ".word");
if (*op1)
! (*prin) (stream, "\t%s", op1);
if (*op2)
(*prin) (stream, ", %s", op2);
--- 366,372 ----
(*prin) (stream, "%s", ok ? opcode->name : ".word");
if (*op1)
! (*prin) (stream, "\t%s", op1);
if (*op2)
(*prin) (stream, ", %s", op2);
*************** print_insn_avr(addr, info)
*** 364,371 ****
--- 374,387 ----
if (*comment1)
(*prin) (stream, "\t; %s", comment1);
+ if (sym_op1)
+ info->print_address_func(sym_addr1, info);
+
if (*comment2)
(*prin) (stream, " %s", comment2);
+ if (sym_op2)
+ info->print_address_func(sym_addr2, info);
+
return cmd_len;
}