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: disassemble moxie addresses


The moxie disassembler currently doesn't print memory addresses any
different from random immediate data.  For instance, today we see code
like...

    1158:       03 00 00 00     jsra    0x1358
    115c:       13 58 

..which is annoying since we have to find 1358 to know that we're
calling free().

This patch changes the disassembler to make use of
info->print_address_func.   Now we get disassemblies like this:

    1158:       03 00 00 00     jsra    1358 <free>
    115c:       13 58 

In order to do this I had to recode a number of opcodes from MOXIE_F1_4
to the new MOXIE_F1_M tag, which means "form 1 instruction with a 4-byte
memory address".

I'm checking this change in.

Thanks,

AG



include/opcode/ChangeLog

2009-06-06  Anthony Green  <green@moxielogic.com>

	* moxie.h (MOXIE_F1_M): Define.


opcodes/ChangeLog

2009-06-06  Anthony Green  <green@moxielogic.com>

	* moxie-opc.c: Recode some MOXIE_F1_4 opcodes as MOXIE_F1_M.
	* moxie-dis.c (print_insn_moxie): Handle MOXIE_F1_M case.


Index: opcodes/moxie-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/moxie-dis.c,v
retrieving revision 1.1
diff -u -r1.1 moxie-dis.c
--- opcodes/moxie-dis.c	16 Apr 2009 15:39:48 -0000	1.1
+++ opcodes/moxie-dis.c	6 Jun 2009 12:44:16 -0000
@@ -93,6 +93,17 @@
 	    length = 6;
 	  }
 	  break;
+	case MOXIE_F1_M:
+	  {
+	    unsigned imm;
+	    if ((status = info->read_memory_func (addr + 2, buffer, 4, info)))
+	      goto fail;
+	    imm = bfd_getb32 (buffer);
+	    fpr (stream, "%s\t", opcode->name);
+	    info->print_address_func ((bfd_vma) imm, info);
+	    length = 6;
+	  }
+	  break;
 	case MOXIE_F1_AiB:
 	  fpr (stream, "%s\t(%s), %s", opcode->name,
 	       reg_names[OP_A(iword)], reg_names[OP_B(iword)]);
Index: opcodes/moxie-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/moxie-opc.c,v
retrieving revision 1.1
diff -u -r1.1 moxie-opc.c
--- opcodes/moxie-opc.c	16 Apr 2009 15:39:48 -0000	1.1
+++ opcodes/moxie-opc.c	6 Jun 2009 12:44:16 -0000
@@ -55,7 +55,7 @@
     { 0x00, MOXIE_F1_NARG, "nop" },
     { 0x01, MOXIE_F1_A4,   "ldi.l" },
     { 0x02, MOXIE_F1_AB,   "mov" },
-    { 0x03, MOXIE_F1_4,    "jsra" },
+    { 0x03, MOXIE_F1_M,    "jsra" },
     { 0x04, MOXIE_F1_NARG, "ret" },
     { 0x05, MOXIE_F1_AB,   "add.l" },
     { 0x06, MOXIE_F1_AB,   "push" },
@@ -67,18 +67,18 @@
     { 0x0c, MOXIE_F1_ABi4, "ldo.l" },
     { 0x0d, MOXIE_F1_AiB4, "sto.l" },
     { 0x0e, MOXIE_F1_AB,   "cmp" },
-    { 0x0f, MOXIE_F1_4,    "beq" },
-    { 0x10, MOXIE_F1_4,    "bne" },
-    { 0x11, MOXIE_F1_4,    "blt" },
-    { 0x12, MOXIE_F1_4,    "bgt" },
-    { 0x13, MOXIE_F1_4,    "bltu" },
-    { 0x14, MOXIE_F1_4,    "bgtu" },
-    { 0x15, MOXIE_F1_4,    "bge" },
-    { 0x16, MOXIE_F1_4,    "ble" },
-    { 0x17, MOXIE_F1_4,    "bgeu" },
-    { 0x18, MOXIE_F1_4,    "bleu" },
+    { 0x0f, MOXIE_F1_M,    "beq" },
+    { 0x10, MOXIE_F1_M,    "bne" },
+    { 0x11, MOXIE_F1_M,    "blt" },
+    { 0x12, MOXIE_F1_M,    "bgt" },
+    { 0x13, MOXIE_F1_M,    "bltu" },
+    { 0x14, MOXIE_F1_M,    "bgtu" },
+    { 0x15, MOXIE_F1_M,    "bge" },
+    { 0x16, MOXIE_F1_M,    "ble" },
+    { 0x17, MOXIE_F1_M,    "bgeu" },
+    { 0x18, MOXIE_F1_M,    "bleu" },
     { 0x19, MOXIE_F1_A,    "jsr" },
-    { 0x1a, MOXIE_F1_4,    "jmpa" },
+    { 0x1a, MOXIE_F1_M,    "jmpa" },
     { 0x1b, MOXIE_F1_A4,   "ldi.b" },
     { 0x1c, MOXIE_F1_ABi,  "ld.b" },
     { 0x1d, MOXIE_F1_A4,   "lda.b" },
Index: include/opcode/moxie.h
===================================================================
RCS file: /cvs/src/src/include/opcode/moxie.h,v
retrieving revision 1.1
diff -u -r1.1 moxie.h
--- include/opcode/moxie.h	16 Apr 2009 15:39:45 -0000	1.1
+++ include/opcode/moxie.h	6 Jun 2009 12:44:16 -0000
@@ -24,6 +24,7 @@
     Some use A and B registers                      (MOXIE_F1_AB)
     Some use A and consume a 4 byte immediate value (MOXIE_F1_A4)
     Some use just a 4 byte immediate value          (MOXIE_F1_4)
+    Some use just a 4 byte memory address           (MOXIE_F1_M)
     Some use B and an indirect A                    (MOXIE_F1_AiB)
     Some use A and an indirect B                    (MOXIE_F1_ABi)
     Some consume a 4 byte immediate value and use X (MOXIE_F1_4A)
@@ -50,6 +51,7 @@
 #define MOXIE_F1_4A   0x108
 #define MOXIE_F1_AiB4 0x109
 #define MOXIE_F1_ABi4 0x10a
+#define MOXIE_F1_M    0x10b
 
 #define MOXIE_F2_NARG 0x200
 #define MOXIE_F2_A8V  0x201



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