X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=opcodes%2Fns32k-dis.c;h=d505edd774267d4c3f93200917a9296792bd4b31;hb=384f368958f2a5bb083660e58e5f8a010e6ad429;hp=5e6f0964b7aa626796f64dab47cfbdc2483ce48d;hpb=fb4cb4e26d16f928f00973fcdc99934c9174c957;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/ns32k-dis.c b/opcodes/ns32k-dis.c index 5e6f0964b7..d505edd774 100644 --- a/opcodes/ns32k-dis.c +++ b/opcodes/ns32k-dis.c @@ -1,5 +1,5 @@ /* Print National Semiconductor 32000 instructions. - Copyright (C) 1986-2019 Free Software Foundation, Inc. + Copyright (C) 1986-2020 Free Software Foundation, Inc. This file is part of the GNU opcodes library. @@ -327,8 +327,8 @@ bit_copy (bfd_byte *buffer, int offset, int count, char *to) static int sign_extend (unsigned int value, unsigned int bits) { - unsigned int sign = 1u << bits; - return ((value & (sign - 1)) ^ sign) - sign; + unsigned int sign = 1u << (bits - 1); + return ((value & (sign + sign - 1)) ^ sign) - sign; } static void @@ -347,9 +347,7 @@ flip_bytes (char *ptr, int count) } /* Given a character C, does it represent a general addressing mode? */ -#define Is_gen(c) \ - ((c) == 'F' || (c) == 'L' || (c) == 'B' \ - || (c) == 'W' || (c) == 'D' || (c) == 'A' || (c) == 'I' || (c) == 'Z') +#define Is_gen(c) (strchr ("FLBWDAIZf", (c)) != NULL) /* Adressing modes. */ #define Adrmod_index_byte 0x1c @@ -808,9 +806,10 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info) if we are using scaled indexed addressing mode, since the index bytes occur right after the basic instruction, not as part of the addressing extension. */ - if (Is_gen(d[1])) + if (Is_gen (d[1])) { - int addr_mode = bit_extract (buffer, ioffset - 5, 5); + int bitoff = d[1] == 'f' ? 10 : 5; + int addr_mode = bit_extract (buffer, ioffset - bitoff, 5); if (Adrmod_is_index (addr_mode)) { @@ -819,7 +818,7 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info) } } - if (d[2] && Is_gen(d[3])) + if (d[2] && Is_gen (d[3])) { int addr_mode = bit_extract (buffer, ioffset - 10, 5);