X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=opcodes%2Fd30v-dis.c;h=ba43731122d80f24995261377e7ba7763d69817f;hb=087e161b3cd9a8626dc05ce1bdb8dfaf353a71b1;hp=61bb16d6d252b1f08c8c286e0d0763999576866e;hpb=b3adc24a0713411ab38a21dc894dd40dbc5c8f4f;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/d30v-dis.c b/opcodes/d30v-dis.c index 61bb16d6d2..ba43731122 100644 --- a/opcodes/d30v-dis.c +++ b/opcodes/d30v-dis.c @@ -123,9 +123,9 @@ print_insn (struct disassemble_info *info, int is_long, int show_ext) { - int val, opnum, need_comma = 0; + unsigned int val, opnum; const struct d30v_operand *oper; - int i, match, need_paren = 0, found_control = 0; + int i, match, need_comma = 0, need_paren = 0, found_control = 0; unsigned int opind = 0; (*info->fprintf_func) (info->stream, "%s", insn->op->name); @@ -271,14 +271,10 @@ print_insn (struct disassemble_info *info, /* IMM6S3 is unsigned. */ if (oper->flags & OPERAND_SIGNED || bits == 32) { - long max; - max = (1 << (bits - 1)); - if (val & max) + unsigned int sign = 1u << (bits - 1); + if (val & sign) { - if (bits == 32) - val = -val; - else - val = -val & ((1 << bits) - 1); + val = -val & (sign + sign - 1); neg = 1; } } @@ -303,13 +299,11 @@ print_insn (struct disassemble_info *info, { if (oper->flags & OPERAND_SIGNED) { - int max = (1 << (bits - 1)); + unsigned int sign = 1u << (bits - 1); - if (val & max) + if (val & sign) { - val = -val; - if (bits < 32) - val &= ((1 << bits) - 1); + val = -val & (sign + sign - 1); (*info->fprintf_func) (info->stream, "-"); } }