summaryrefslogtreecommitdiff
path: root/opcodes/m32c-ibld.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2006-03-05 08:38:53 +0000
committerNick Clifton <nickc@redhat.com>2006-03-05 08:38:53 +0000
commit4f16862c5418a4482c73310a6b1f107801faf4a0 (patch)
treec07ead120e502a6ffb77e3474fc4f83082354f9b /opcodes/m32c-ibld.c
parent3e76e9c91a42a8555926c3f0627ddab3e423bb17 (diff)
downloadbinutils-redhat-4f16862c5418a4482c73310a6b1f107801faf4a0.tar.gz
* cgen-ibld.in (insert_normal): Cope with attempts to insert a signed 32-bit
value into an unsigned 32-bit field when the host is a 64-bit machine.
Diffstat (limited to 'opcodes/m32c-ibld.c')
-rw-r--r--opcodes/m32c-ibld.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/opcodes/m32c-ibld.c b/opcodes/m32c-ibld.c
index 62c753b934..7601128c63 100644
--- a/opcodes/m32c-ibld.c
+++ b/opcodes/m32c-ibld.c
@@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd,
else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
{
unsigned long maxval = mask;
-
- if ((unsigned long) value > maxval)
+ unsigned long val = (unsigned long) value;
+
+ /* For hosts with a word size > 32 check to see if value has been sign
+ extended beyond 32 bits. If so then ignore these higher sign bits
+ as the user is attempting to store a 32-bit signed value into an
+ unsigned 32-bit field which is allowed. */
+ if (sizeof (unsigned long) > 4 && ((value >> 32) == -1))
+ val &= 0xFFFFFFFF;
+
+ if (val > maxval)
{
/* xgettext:c-format */
sprintf (errbuf,
- _("operand out of range (%lu not between 0 and %lu)"),
- value, maxval);
+ _("operand out of range (0x%lx not between 0 and 0x%lx)"),
+ val, maxval);
return errbuf;
}
}