public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] s390-dis.c: Fix formatting.
@ 2001-07-22 12:26 Kazu Hirata
  0 siblings, 0 replies; 85+ messages in thread
From: Kazu Hirata @ 2001-07-22 12:26 UTC (permalink / raw)
  To: binutils

Hi,

Attached is a patch to fix formatting s390-dis.c.  OK to apply?

Thanks,

Kazu Hirata

2001-07-22  Kazu Hirata  <kazu@hxi.com>

	* s390-dis.c: Fix formatting.

Index: s390-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/s390-dis.c,v
retrieving revision 1.2
diff -u -r1.2 s390-dis.c
--- s390-dis.c	2001/03/13 22:58:37	1.2
+++ s390-dis.c	2001/07/22 19:19:15
@@ -29,32 +29,35 @@
 static int opc_index[256];
 static int current_arch_mask = 0;
 
-/* Set up index table for first opcode byte */
-static void 
-init_disasm(info)
-    struct disassemble_info *info ATTRIBUTE_UNUSED;
+/* Set up index table for first opcode byte.  */
+
+static void
+init_disasm (info)
+     struct disassemble_info *info ATTRIBUTE_UNUSED;
 {
   const struct s390_opcode *opcode;
   const struct s390_opcode *opcode_end;
 
-  memset(opc_index, 0, sizeof(opc_index));
+  memset (opc_index, 0, sizeof (opc_index));
   opcode_end = s390_opcodes + s390_num_opcodes;
-  for (opcode = s390_opcodes; opcode < opcode_end; opcode++) {
-    opc_index[(int) opcode->opcode[0]] = opcode - s390_opcodes;
-    while ((opcode < opcode_end) && 
-           (opcode[1].opcode[0] == opcode->opcode[0]))
-      opcode++;
-  }
-  switch (info->mach) {
-  case bfd_mach_s390_esa:
-    current_arch_mask = 1 << S390_OPCODE_ESA;
-    break;
-  case bfd_mach_s390_esame:
-    current_arch_mask = 1 << S390_OPCODE_ESAME;
-    break;
-  default:
-    abort();
-  }
+  for (opcode = s390_opcodes; opcode < opcode_end; opcode++)
+    {
+      opc_index[(int) opcode->opcode[0]] = opcode - s390_opcodes;
+      while ((opcode < opcode_end) &&
+	     (opcode[1].opcode[0] == opcode->opcode[0]))
+	opcode++;
+    }
+  switch (info->mach)
+    {
+    case bfd_mach_s390_esa:
+      current_arch_mask = 1 << S390_OPCODE_ESA;
+      break;
+    case bfd_mach_s390_esame:
+      current_arch_mask = 1 << S390_OPCODE_ESAME;
+      break;
+    default:
+      abort ();
+    }
   init_flag = 1;
 }
 
@@ -68,28 +71,30 @@
   unsigned int val;
   int bits;
 
-  /* extract fragments of the operand byte for byte */
-  insn += operand->shift/8;
+  /* Extract fragments of the operand byte for byte.  */
+  insn += operand->shift / 8;
   bits = (operand->shift & 7) + operand->bits;
   val = 0;
-  do {
-    val <<= 8;
-    val |= (unsigned int) *insn++;
-    bits -= 8;
-  } while (bits > 0);
+  do
+    {
+      val <<= 8;
+      val |= (unsigned int) *insn++;
+      bits -= 8;
+    }
+  while (bits > 0);
   val >>= -bits;
-  val &= ((1U << (operand->bits-1))<<1) - 1;
+  val &= ((1U << (operand->bits - 1)) << 1) - 1;
 
-  /* sign extend value if the operand is signed or pc relative */
-  if ((operand->flags & (S390_OPERAND_SIGNED|S390_OPERAND_PCREL)) &&
-      (val & (1U << (operand->bits-1))))
-    val |= (-1U << (operand->bits-1))<<1;
- 
-  /* double value if the operand is pc relative */
+  /* Sign extend value if the operand is signed or pc relative.  */
+  if ((operand->flags & (S390_OPERAND_SIGNED | S390_OPERAND_PCREL))
+      && (val & (1U << (operand->bits - 1))))
+    val |= (-1U << (operand->bits - 1)) << 1;
+
+  /* Double value if the operand is pc relative.  */
   if (operand->flags & S390_OPERAND_PCREL)
     val <<= 1;
- 
-  /* length x in an instructions has real length x+1 */
+
+  /* Length x in an instructions has real length x+1.  */
   if (operand->flags & S390_OPERAND_LENGTH)
     val++;
   return val;
@@ -110,122 +115,139 @@
   char separator;
 
   if (init_flag == 0)
-    init_disasm(info);
+    init_disasm (info);
 
   /* The output looks better if we put 6 bytes on a line.  */
   info->bytes_per_line = 6;
 
   /* Every S390 instruction is max 6 bytes long.  */
-  memset(buffer, 0, 6);
+  memset (buffer, 0, 6);
   status = (*info->read_memory_func) (memaddr, buffer, 6, info);
-  if (status != 0) {
-    for (bufsize = 0; bufsize < 6; bufsize++)
-      if ((*info->read_memory_func) (memaddr, buffer, bufsize+1, info) != 0)
-        break;
-    if (bufsize <= 0) {
-      (*info->memory_error_func) (status, memaddr, info);
-      return -1;
-    }
-    /* Opsize calculation looks strange but it works
-       00xxxxxx -> 2 bytes, 01xxxxxx/10xxxxxx -> 4 bytes, 
-       11xxxxxx -> 6 bytes.  */
-    opsize = ((((buffer[0]>>6)+1)>>1)+1)<<1;
-    status = opsize > bufsize;
-  } else {
-    bufsize = 6;
-    opsize = ((((buffer[0]>>6)+1)>>1)+1)<<1;
-  }
-
-  if (status == 0) {
-    /* Find the first match in the opcode table.  */
-    opcode_end = s390_opcodes + s390_num_opcodes;
-    for (opcode = s390_opcodes + opc_index[(int) buffer[0]]; 
-         (opcode < opcode_end) && (buffer[0] == opcode->opcode[0]);
-         opcode++) {
-      const struct s390_operand *operand;
-      const unsigned char *opindex;
-
-      /* check architecture */
-      if (!(opcode->architecture & current_arch_mask))
-        continue;
-      /* check signature of the opcode */
-      if ((buffer[1] & opcode->mask[1]) != opcode->opcode[1] ||
-          (buffer[2] & opcode->mask[2]) != opcode->opcode[2] ||
-          (buffer[3] & opcode->mask[3]) != opcode->opcode[3] ||
-          (buffer[4] & opcode->mask[4]) != opcode->opcode[4] ||
-          (buffer[5] & opcode->mask[5]) != opcode->opcode[5])
-        continue;
-  
-      /* the instruction is valid */
-      if (opcode->operands[0] != 0)
-        (*info->fprintf_func) (info->stream, "%s\t", opcode->name);
-      else
-        (*info->fprintf_func) (info->stream, "%s", opcode->name);
-  
-      /* Extract the operands.  */
-      separator = 0;
-      for (opindex = opcode->operands; *opindex != 0; opindex++) {
-        unsigned int value;
-
-        operand = s390_operands + *opindex;
-        value = s390_extract_operand(buffer, operand);
-
-        if ((operand->flags & S390_OPERAND_INDEX) && value == 0)
-          continue;
-        if ((operand->flags & S390_OPERAND_BASE) && 
-            value == 0 && separator == '(') {
-          separator = ',';
-          continue;
-        }
-
-        if (separator)
-          (*info->fprintf_func) (info->stream, "%c", separator);
-
-        if (operand->flags & S390_OPERAND_GPR)
-          (*info->fprintf_func) (info->stream, "%%r%i", value);
-        else if (operand->flags & S390_OPERAND_FPR)
-          (*info->fprintf_func) (info->stream, "%%f%i", value);
-        else if (operand->flags & S390_OPERAND_AR)
-          (*info->fprintf_func) (info->stream, "%%a%i", value);
-        else if (operand->flags & S390_OPERAND_CR)
-          (*info->fprintf_func) (info->stream, "%%c%i", value);
-        else if (operand->flags & S390_OPERAND_PCREL)
-          (*info->print_address_func) (memaddr + (int) value, info);
-        else if (operand->flags & S390_OPERAND_SIGNED)
-          (*info->fprintf_func) (info->stream, "%i", (int) value);
-        else
-	  (*info->fprintf_func) (info->stream, "%i", value);
-
-        if (operand->flags & S390_OPERAND_DISP) {
-	  separator = '(';
-        } else if (operand->flags & S390_OPERAND_BASE) {
-	  (*info->fprintf_func) (info->stream, ")");
-          separator = ',';
-        } else
-	  separator = ',';
-      }
-
-      /* found instruction, printed it, return its size */
-      return opsize;
-    }
-    /* no matching instruction found, fall through to hex print  */
-  }
-
-  if (bufsize >= 4) {
-    value = (unsigned int) buffer[0];
-    value = (value << 8) + (unsigned int) buffer[1];
-    value = (value << 8) + (unsigned int) buffer[2];
-    value = (value << 8) + (unsigned int) buffer[3];
-    (*info->fprintf_func) (info->stream,".long\t0x%08x", value);
-    return 4;
-  } else if (bufsize >= 2) {
-    value = (unsigned int) buffer[0];
-    value = (value << 8) + (unsigned int) buffer[1];
-    (*info->fprintf_func) (info->stream,".short\t0x%04x", value);
-    return 2;
-  } else {
-    value = (unsigned int) buffer[0];
-    (*info->fprintf_func) (info->stream,".byte\t0x%02x", value);
-    return 1;
-  }
+  if (status != 0)
+    {
+      for (bufsize = 0; bufsize < 6; bufsize++)
+	if ((*info->read_memory_func) (memaddr, buffer, bufsize + 1, info) != 0)
+	  break;
+      if (bufsize <= 0)
+	{
+	  (*info->memory_error_func) (status, memaddr, info);
+	  return -1;
+	}
+      /* Opsize calculation looks strange but it works
+	 00xxxxxx -> 2 bytes, 01xxxxxx/10xxxxxx -> 4 bytes,
+	 11xxxxxx -> 6 bytes.  */
+      opsize = ((((buffer[0] >> 6) + 1) >> 1) + 1) << 1;
+      status = opsize > bufsize;
+    }
+  else
+    {
+      bufsize = 6;
+      opsize = ((((buffer[0] >> 6) + 1) >> 1) + 1) << 1;
+    }
+
+  if (status == 0)
+    {
+      /* Find the first match in the opcode table.  */
+      opcode_end = s390_opcodes + s390_num_opcodes;
+      for (opcode = s390_opcodes + opc_index[(int) buffer[0]];
+	   (opcode < opcode_end) && (buffer[0] == opcode->opcode[0]);
+	   opcode++)
+	{
+	  const struct s390_operand *operand;
+	  const unsigned char *opindex;
+
+	  /* Check architecture.  */
+	  if (!(opcode->architecture & current_arch_mask))
+	    continue;
+	  /* Check signature of the opcode.  */
+	  if ((buffer[1] & opcode->mask[1]) != opcode->opcode[1]
+	      || (buffer[2] & opcode->mask[2]) != opcode->opcode[2]
+	      || (buffer[3] & opcode->mask[3]) != opcode->opcode[3]
+	      || (buffer[4] & opcode->mask[4]) != opcode->opcode[4]
+	      || (buffer[5] & opcode->mask[5]) != opcode->opcode[5])
+	    continue;
+
+	  /* The instruction is valid.  */
+	  if (opcode->operands[0] != 0)
+	    (*info->fprintf_func) (info->stream, "%s\t", opcode->name);
+	  else
+	    (*info->fprintf_func) (info->stream, "%s", opcode->name);
+
+	  /* Extract the operands.  */
+	  separator = 0;
+	  for (opindex = opcode->operands; *opindex != 0; opindex++)
+	    {
+	      unsigned int value;
+
+	      operand = s390_operands + *opindex;
+	      value = s390_extract_operand (buffer, operand);
+
+	      if ((operand->flags & S390_OPERAND_INDEX) && value == 0)
+		continue;
+	      if ((operand->flags & S390_OPERAND_BASE) &&
+		  value == 0 && separator == '(')
+		{
+		  separator = ',';
+		  continue;
+		}
+
+	      if (separator)
+		(*info->fprintf_func) (info->stream, "%c", separator);
+
+	      if (operand->flags & S390_OPERAND_GPR)
+		(*info->fprintf_func) (info->stream, "%%r%i", value);
+	      else if (operand->flags & S390_OPERAND_FPR)
+		(*info->fprintf_func) (info->stream, "%%f%i", value);
+	      else if (operand->flags & S390_OPERAND_AR)
+		(*info->fprintf_func) (info->stream, "%%a%i", value);
+	      else if (operand->flags & S390_OPERAND_CR)
+		(*info->fprintf_func) (info->stream, "%%c%i", value);
+	      else if (operand->flags & S390_OPERAND_PCREL)
+		(*info->print_address_func) (memaddr + (int) value, info);
+	      else if (operand->flags & S390_OPERAND_SIGNED)
+		(*info->fprintf_func) (info->stream, "%i", (int) value);
+	      else
+		(*info->fprintf_func) (info->stream, "%i", value);
+
+	      if (operand->flags & S390_OPERAND_DISP)
+		{
+		  separator = '(';
+		}
+	      else if (operand->flags & S390_OPERAND_BASE)
+		{
+		  (*info->fprintf_func) (info->stream, ")");
+		  separator = ',';
+		}
+	      else
+		separator = ',';
+	    }
+
+	  /* Found instruction, printed it, return its size.  */
+	  return opsize;
+	}
+      /* No matching instruction found, fall through to hex print.  */
+    }
+
+  if (bufsize >= 4)
+    {
+      value = (unsigned int) buffer[0];
+      value = (value << 8) + (unsigned int) buffer[1];
+      value = (value << 8) + (unsigned int) buffer[2];
+      value = (value << 8) + (unsigned int) buffer[3];
+      (*info->fprintf_func) (info->stream, ".long\t0x%08x", value);
+      return 4;
+    }
+  else if (bufsize >= 2)
+    {
+      value = (unsigned int) buffer[0];
+      value = (value << 8) + (unsigned int) buffer[1];
+      (*info->fprintf_func) (info->stream, ".short\t0x%04x", value);
+      return 2;
+    }
+  else
+    {
+      value = (unsigned int) buffer[0];
+      (*info->fprintf_func) (info->stream, ".byte\t0x%02x", value);
+      return 1;
+    }
 }

^ permalink raw reply	[flat|nested] 85+ messages in thread

end of thread, other threads:[~2009-08-14  7:43 UTC | newest]

Thread overview: 85+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <no.id>
1999-07-01  0:00 ` Duplicate symbols in recent cvs source John David Anglin
1999-07-01  0:00   ` John David Anglin
1999-07-01  0:00 ` #error ELF_MAXPAGESIZE is not defined John David Anglin
2000-04-09 13:44 ` Errors compiling coff-tic54x.c from todays CVS source John David Anglin
2000-09-22 16:56 ` gas 2.10.91 from 20000920 cvs is broken under hpux 10.20 John David Anglin
2000-09-22 18:49   ` Alan Modra
2000-09-22 22:42   ` John David Anglin
2000-09-22 23:11     ` Alan Modra
2000-09-24 15:25 ` [Patch]: " John David Anglin
2000-09-26 10:03 ` [Patch]: Re: gas 2.10.91 from 20000920 cvs is broken under hpux John David Anglin
2000-09-26 13:24   ` John David Anglin
2000-09-26 18:16     ` Alan Modra
2000-09-26 20:54       ` John David Anglin
2000-09-28  1:42     ` Alan Modra
2001-03-14 15:52 ` vax quad.exp testsuite failure John David Anglin
2001-03-15  3:05   ` Alan Modra
2001-03-15  8:15     ` John David Anglin
2001-03-14 16:06 ` John David Anglin
2001-07-22 16:35 ` [patch] tc-*.[ch]: Fix formatting Alan Modra
2001-07-22 16:38 ` [patch] s390-dis.c: " Alan Modra
2001-07-23 17:10 ` [patch] *-dis.c: " Alan Modra
2001-07-23 19:22 ` [patch] *-dis.c: Fix formatting. (2nd set) Alan Modra
2001-07-24 17:33 ` [patch] d?0v-dis.c: Fix formatting Alan Modra
2001-07-28 20:48 ` [patch] i386-dis.c: " Alan Modra
2002-02-09 17:47 ` Special names tha ld needs to recognize for hppa64-hp-hpux11.X John David Anglin
2002-02-12 16:14 ` John David Anglin
2002-02-12 17:38   ` law
2002-02-26 15:20     ` John David Anglin
2002-02-26 21:58       ` Alan Modra
2002-02-27  0:32         ` John David Anglin
2002-03-05  9:57       ` law
2002-04-25  8:59 ` i386-pc-nto-qnx patch Graeme Peterson
2002-04-25  9:09   ` H . J . Lu
2002-04-25 10:04     ` gp
2002-04-25 23:40   ` J.T. Conklin
2002-05-09  8:20 ` Graeme Peterson
2002-05-10  6:31   ` Alan Modra
2002-05-10  7:55     ` Graeme Peterson
2002-05-13  8:42     ` Graeme Peterson
2002-05-10  9:57 ` Graeme Peterson
2002-06-05 23:05 ` Miscellaneous fixes for testsuite failures on hppa64-hp-hpux11.00 John David Anglin
2002-06-05 23:14   ` law
2002-06-22 23:12 ` PATCH: Re: hppa64-hp-hpux11.00: invalid string offset for section .dynstr John David Anglin
2002-06-23  2:07   ` Alan Modra
2002-06-27 10:33 ` hpux64-hp-hpux11.00: .rela.opd problems John David Anglin
2002-07-16 17:43 ` SIGSEGV in ld at elflink.h:5500 John David Anglin
2002-07-16 18:51   ` Alan Modra
2002-07-16 19:34     ` John David Anglin
2002-07-16 21:39       ` Alan Modra
2002-07-16 21:49     ` John David Anglin
2002-07-16 22:46       ` Alan Modra
2002-07-17  0:12         ` John David Anglin
2002-07-17 20:35         ` John David Anglin
2002-07-17 23:07           ` Alan Modra
2002-07-17 23:42             ` John David Anglin
2002-07-18  0:14               ` Alan Modra
2002-07-18  3:11                 ` John David Anglin
2002-10-18 13:43 ` QNX binutils targets Graeme Peterson
2002-10-24 19:42 ` K&R patch for binutils bfd directory John David Anglin
2002-12-03  8:31 ` Patch to config.guess (2002-07-03) to detect 64bit HPUX compiler John David Anglin
2002-12-03 16:51   ` John David Anglin
2002-12-04  1:53     ` Ben Elliston
2002-12-17  8:51 ` Setting LD tool default to ld breaks configure check for ld used by GCC John David Anglin
2002-12-20 17:56   ` John David Anglin
2003-05-21 18:07 ` [BFD PATCH] File truncation in objcopy for hppa2.0w-hp-hpux11.11 in binutils-2.13.1 John David Anglin
2003-05-21 20:00   ` [BFD PATCH] " Stuart F. Downing
2003-05-22  3:41   ` [BFD PATCH] " John David Anglin
2003-05-22 15:46     ` Daniel Jacobowitz
2003-05-22 15:59       ` John David Anglin
2003-05-23 15:06         ` Daniel Jacobowitz
2004-03-20 23:37 ` [committed] Add support for PCREL32 and PCREL64 relocations on PA John David Anglin
2004-06-11 17:54 ` [PATCH] Allow reduction of fake labels " John David Anglin
2005-06-16  3:32 ` hppa build broken John David Anglin
2006-03-04 22:15 ` [hppa] Fix disassembly of bb condition codes John David Anglin
2006-03-05  6:22   ` Randolph Chung
2009-08-14  7:43   ` Nick Hudson
2007-12-28 23:47 ` hppa unwind entries John David Anglin
2007-12-29  9:15   ` Nick Clifton
2007-12-29 15:52     ` Nick Clifton
2007-12-29 17:16       ` John David Anglin
2007-12-30 15:46         ` Nick Clifton
2007-12-30 17:13           ` John David Anglin
2007-12-31 11:01             ` Nick Clifton
2009-02-15 19:45 ` [committed] Ensure pc-relative calls can reach their target on hppa64 John David Anglin
2001-07-22 12:26 [patch] s390-dis.c: Fix formatting Kazu Hirata

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).