aboutsummaryrefslogtreecommitdiff
path: root/opcodes/cgen-asm.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2011-12-15 10:21:51 +0000
committerNick Clifton <nickc@redhat.com>2011-12-15 10:21:51 +0000
commit5011093dd0015bc0eaff522b4e0a18250725d4b4 (patch)
treeda04ec25c27553e8690c4029cb23fea59cdb2f9c /opcodes/cgen-asm.c
parent370a075d4837b62334a012279faaa95cf8028f51 (diff)
downloadgdb-5011093dd0015bc0eaff522b4e0a18250725d4b4.zip
gdb-5011093dd0015bc0eaff522b4e0a18250725d4b4.tar.gz
gdb-5011093dd0015bc0eaff522b4e0a18250725d4b4.tar.bz2
* frv.opc (parse_uhi16): Fix handling of %hi operator on 64-bit
hosts. * cgen-asm.c (cgen_parse_signed_integer): Add code to handle the sign extension of negative values on a 64-bit host. * frv-asm.c: Regenerate. * gas/frv/immediates.s: New test file - checks assembly of constant values. * gas/frv/immediates.d: Expected disassmbly. * gas/frv/allinsn.exp: Run the new test.
Diffstat (limited to 'opcodes/cgen-asm.c')
-rw-r--r--opcodes/cgen-asm.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/opcodes/cgen-asm.c b/opcodes/cgen-asm.c
index f5fde40..901a578 100644
--- a/opcodes/cgen-asm.c
+++ b/opcodes/cgen-asm.c
@@ -1,6 +1,6 @@
/* CGEN generic assembler support code.
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007
- Free Software Foundation, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007,
+ 2011 Free Software Foundation, Inc.
This file is part of libopcodes.
@@ -268,7 +268,23 @@ cgen_parse_signed_integer (CGEN_CPU_DESC cd,
&result, &value);
/* FIXME: Examine `result'. */
if (!errmsg)
- *valuep = value;
+ {
+ /* Handle the case where a hex value is parsed on a 64-bit host.
+ A value like 0xffffe000 is clearly intended to be a negative
+ 16-bit value, but on a 64-bit host it will be parsed by gas
+ as 0x00000000ffffe000.
+
+ The shifts below are designed not to produce compile time
+ warnings on a 32-bit host. */
+ if (sizeof (value) > 4
+ && result == CGEN_PARSE_OPERAND_RESULT_NUMBER
+ && value > 0
+ && (value & 0x80000000)
+ && ((value >> 31) == 1))
+ value |= -1 << 31;
+
+ *valuep = value;
+ }
return errmsg;
}