This is the mail archive of the binutils@sourceware.cygnus.com 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]

Re: 64-bit clean-up in mn10300 disassembler


On May 24, 2000, Alan Modra <alan@linuxcare.com.au> wrote:

> On 24 May 2000, Alexandre Oliva wrote:
> +                 && (value & (1 << (operand->bits - 1))))
> +               value |= (((unsigned long)0) - 1) << (operand->bits - 1);

> value = ((value ^ ((unsigned long)1 << (operand->bits - 1)))
>          - ((unsigned long)1 << (operand->bits - 1)))

> should compile better.  Also, you forgot to cast 1 to unsigned long.

Indeed, thanks.  Here's a revised patch.  Ok to install?

> On another issue, what about MN10300_OPERAND_SPLIT?  Does this need
> to be sign extended in some cases?

Nope, it's always 32-bits wide.  Well, it could be argued that we
should sign-extend it to 64-bits when appropriate, but I haven't
encountered any failure related with the lack of sign-extension.
Probably because value (which is unsigned long) is printed with "%d",
which is a problem in itself.

Index: opcodes/ChangeLog
from  Alexandre Oliva  <aoliva@cygnus.com>

	* m10300-dis.c (disassemble): Don't assume 32-bit longs when
	sign-extending operands.

Index: opcodes/m10300-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/m10300-dis.c,v
retrieving revision 1.4
diff -u -r1.4 m10300-dis.c
--- opcodes/m10300-dis.c	2000/04/20 22:15:32	1.4
+++ opcodes/m10300-dis.c	2000/05/24 14:28:00
@@ -508,11 +508,10 @@
 		}
 
 	      if ((operand->flags & MN10300_OPERAND_SIGNED) != 0
-		   /* These are properly extended by the code above.  */
-		   && ((operand->flags & MN10300_OPERAND_24BIT) == 0)
-		  )
-		value = ((long)(value << (32 - operand->bits))
-			  >> (32 - operand->bits));
+		  /* These are properly extended by the code above.  */
+		  && ((operand->flags & MN10300_OPERAND_24BIT) == 0))
+		value = ((value ^ ((unsigned long)1) << (operand->bits - 1))
+			 - (((unsigned long)1) << (operand->bits - 1)));
 
 	      if (!nocomma
 		  && (!paren

-- 
Alexandre Oliva    Enjoy Guaranį, see http://www.ic.unicamp.br/~oliva/
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org}   Write to mailing lists, not to me

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