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]

[msp430] fix bounds check in 20-bit values


The 16-bit checks use -0x8000, the 20-bit checks should use -0x80000.
This shows up if you try to set the MSB of a 20-bit register.  Ok to
commit?

	* config/tc-msp430.c (msp430_srcoperand): Fix bounds check.
	(msp430_operands): Likewise.

diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c
index 1398b8c..5b1d1c4 100644
--- a/gas/config/tc-msp430.c
+++ b/gas/config/tc-msp430.c
@@ -1132,7 +1132,7 @@ msp430_srcoperand (struct msp430_operand_s * op,
 
 	  if (allow_20bit_values)
 	    {
-	      if (op->exp.X_add_number > 0xfffff || op->exp.X_add_number < - (0x7ffff))
+	      if (op->exp.X_add_number > 0xfffff || op->exp.X_add_number < - (0x80000))
 		{
 		  as_bad (_("value 0x%x out of extended range."), x);
 		  return 1;
@@ -1311,7 +1311,7 @@ msp430_srcoperand (struct msp430_operand_s * op,
 
 	  if (allow_20bit_values)
 	    {
-	      if (x > 0xfffff || x < -(0x7ffff))
+	      if (x > 0xfffff || x < -(0x80000))
 		{
 		  as_bad (_("value 0x%x out of extended range."), x);
 		  return 1;
@@ -1420,7 +1420,7 @@ msp430_srcoperand (struct msp430_operand_s * op,
 
 	  if (allow_20bit_values)
 	    {
-	      if (x > 0xfffff || x < - (0x7ffff))
+	      if (x > 0xfffff || x < - (0x80000))
 		{
 		  as_bad (_("value 0x%x out of extended range."), x);
 		  return 1;
@@ -2558,7 +2558,7 @@ msp430_operands (struct msp430_opcode_s * opcode, char * line)
 		if (op1.exp.X_op == O_constant)
 		  {
 		    n = op1.exp.X_add_number;
-		    if (n > 0xfffff || n < - (0x7ffff))
+		    if (n > 0xfffff || n < - (0x80000))
 		      {
 			as_bad (_("expected value of first argument of %s to fit into 20-bits"),
 				opcode->name);


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