This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] add pretty-printing of AVR register names


Hello

When doing objdump --disassemble on ELF for Atmel AVR arch then
current version of binutils does output like this:
  ...
  out	0x3f, r1	; 63

This is technically correct however it is not clear which register
0x3f is written.
If your faith is "IO and ALU registers do not overlap and should be
numbered uniquely"  then 0x3f means EEARH.
If your faith is "dump whatever value is encoded in the instruction
unless the bit pattern is discontinuous" then 0x3f means SREG.

This patch prints names of 3 most common registers which are always at
the same address. (There might be more fixed registers). The output
will look like:

  out	0x3f, r1	; 63 SREG


diff --unif opcodes.orig/avr-dis.c opcodes/avr-dis.c
--- opcodes.orig/avr-dis.c      2010-08-08 18:23:54.911927000 +0200
+++ opcodes/avr-dis.c   2010-08-08 18:28:01.749357800 +0200
@@ -213,7 +213,14 @@
        x = (insn & 0xf);
        x |= (insn >> 5) & 0x30;
        sprintf (buf, "0x%02x", x);
-       sprintf (comment, "%d", x);
+       if (x == 0x3f)
+         sprintf (comment, "%d SREG", x);
+       else if (x == 0x3e)
+         sprintf (comment, "%d SPH", x);
+       else if (x == 0x3d)
+         sprintf (comment, "%d SPL", x);
+       else
+         sprintf (comment, "%d", x);
       }
       break;

These registers are placed at these addresses for all device flavors.
(Assuming that they exist at all.)
Verified by this command:
$ for i in Partdescriptionfiles/*.xml ; do cat $i | awk '$1== "<SPH>"
{inside=1} inside==1 && $1 ~ /
IO_ADDR/ {print}  $1== "</SPH>" {inside=0}' ; done

(If you have an easier way to parse XML files, tell me.)

-- 
Petr Hluzin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]