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]

Moxie patch 3 of 4: disassemble and define PC-relative branch instructions


This patch changes the encoding of branches from 48-bits to 16-bit.
It also tells binutils how to disassemble them nicely.  I'll commit it
once patch 1 has been approved.


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

	* moxie-opc.c (moxie_form1_opc_info): Remove branch instructions.
	(moxie_form3_opc_info): Add branch instructions.
	* moxie-dis.c (print_insn_moxie): Disassemble MOXIE_F3_PCREL
	encoded instructions.


Index: opcodes/moxie-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/moxie-dis.c,v
retrieving revision 1.2
diff -u -r1.2 moxie-dis.c
--- opcodes/moxie-dis.c	6 Jun 2009 13:02:21 -0000	1.2
+++ opcodes/moxie-dis.c	10 Jun 2009 15:34:50 -0000
@@ -33,6 +33,7 @@
 /* Macros to extract operands from the instruction word.  */
 #define OP_A(i) ((i >> 4) & 0xf)
 #define OP_B(i) (i & 0xf)
+#define INST2OFFSET(o) ((((signed short)((o & ((1<<10)-1))<<6))>>6)<<1)
 
 static const char * reg_names[16] =
   { "$fp", "$sp", "$r0", "$r1", "$r2", "$r3", "$r4", "$r5",
@@ -176,11 +177,13 @@
   else
     {
       /* Extract the Form 3 opcode.  */
-      opcode = &moxie_form2_opc_info[(iword >> 12) & 3];
+      opcode = &moxie_form3_opc_info[(iword >> 10) & 15];
       switch (opcode->itype)
 	{
-	case MOXIE_F3_NARG:
-	  fpr (stream, "%s", opcode->name);
+	case MOXIE_F3_PCREL:
+	  fpr (stream, "%s\t", opcode->name);
+	  info->print_address_func ((bfd_vma) (addr + INST2OFFSET(iword)), 
+				    info);
 	  break;
 	default:
 	  abort();
Index: opcodes/moxie-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/moxie-opc.c,v
retrieving revision 1.2
diff -u -r1.2 moxie-opc.c
--- opcodes/moxie-opc.c	6 Jun 2009 13:02:21 -0000	1.2
+++ opcodes/moxie-opc.c	10 Jun 2009 19:38:35 -0000
@@ -44,11 +44,11 @@
 
   FORM 3 instructions start with a bits "11"...
 
-    11oovvvvvvvvvvvv
+    11oooovvvvvvvvvv
     0              F
 
-   oo           - form 3 opcode number
-   vvvvvvvvvvvv - 12-bit immediate value.  */
+   oooo         - form 3 opcode number
+   vvvvvvvvvv   - 10-bit immediate value.  */
 
 const moxie_opc_info_t moxie_form1_opc_info[64] =
   {
@@ -67,16 +67,16 @@
     { 0x0c, MOXIE_F1_ABi4, "ldo.l" },
     { 0x0d, MOXIE_F1_AiB4, "sto.l" },
     { 0x0e, MOXIE_F1_AB,   "cmp" },
-    { 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" },
+    { 0x0f, MOXIE_F1_NARG, "bad" },
+    { 0x10, MOXIE_F1_NARG, "bad" },
+    { 0x11, MOXIE_F1_NARG, "bad" },
+    { 0x12, MOXIE_F1_NARG, "bad" },
+    { 0x13, MOXIE_F1_NARG, "bad" },
+    { 0x14, MOXIE_F1_NARG, "bad" },
+    { 0x15, MOXIE_F1_NARG, "bad" },
+    { 0x16, MOXIE_F1_NARG, "bad" },
+    { 0x17, MOXIE_F1_NARG, "bad" },
+    { 0x18, MOXIE_F1_NARG, "bad" },
     { 0x19, MOXIE_F1_A,    "jsr" },
     { 0x1a, MOXIE_F1_M,    "jmpa" },
     { 0x1b, MOXIE_F1_A4,   "ldi.b" },
@@ -126,11 +126,24 @@
     { 0x03, MOXIE_F2_A8V,  "ssr" }
   };
 
-const moxie_opc_info_t moxie_form3_opc_info[4] =
+const moxie_opc_info_t moxie_form3_opc_info[16] =
   {
-    { 0x00, MOXIE_F2_NARG, "bad" },
-    { 0x01, MOXIE_F2_NARG, "bad" },
-    { 0x02, MOXIE_F2_NARG, "bad" },
-    { 0x03, MOXIE_F2_NARG, "bad" }
+    { 0x00, MOXIE_F3_PCREL,"beq" },
+    { 0x01, MOXIE_F3_PCREL,"bne" },
+    { 0x02, MOXIE_F3_PCREL,"blt" },
+    { 0x03, MOXIE_F3_PCREL,"bgt" },
+    { 0x04, MOXIE_F3_PCREL,"bltu" },
+    { 0x05, MOXIE_F3_PCREL,"bgtu" },
+    { 0x06, MOXIE_F3_PCREL,"bge" },
+    { 0x07, MOXIE_F3_PCREL,"ble" },
+    { 0x08, MOXIE_F3_PCREL,"bgeu" },
+    { 0x09, MOXIE_F3_PCREL,"bleu" },
+    { 0x0a, MOXIE_F3_NARG, "bad" },
+    { 0x0b, MOXIE_F3_NARG, "bad" },
+    { 0x0c, MOXIE_F3_NARG, "bad" },
+    { 0x0d, MOXIE_F3_NARG, "bad" },
+    { 0x0e, MOXIE_F3_NARG, "bad" },
+    { 0x0f, MOXIE_F3_NARG, "bad" }
   };
 
+



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