* [msp430] fix bounds check in 20-bit values
@ 2014-06-19 1:56 DJ Delorie
0 siblings, 0 replies; only message in thread
From: DJ Delorie @ 2014-06-19 1:56 UTC (permalink / raw)
To: binutils
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-06-19 1:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-19 1:56 [msp430] fix bounds check in 20-bit values DJ Delorie
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).