include/opcode/
[deliverable/binutils-gdb.git] / opcodes / ppc-dis.c
index 691c2f6d3e6ab688dc495d85d804a842552c553a..557e5a583fd26e273fa1913b439d5a4aa23af04f 100644 (file)
@@ -222,10 +222,18 @@ print_insn_powerpc (bfd_vma memaddr,
            value = (*operand->extract) (insn, dialect, &invalid);
          else
            {
-             value = (insn >> operand->shift) & ((1 << operand->bits) - 1);
-             if ((operand->flags & PPC_OPERAND_SIGNED) != 0
-                 && (value & (1 << (operand->bits - 1))) != 0)
-               value -= 1 << operand->bits;
+             value = (insn >> operand->shift) & operand->bitm;
+             if ((operand->flags & PPC_OPERAND_SIGNED) != 0)
+               {
+                 /* BITM is always some number of zeros followed by some
+                    number of ones, followed by some numer of zeros.  */
+                 unsigned long top = operand->bitm;
+                 /* top & -top gives the rightmost 1 bit, so this
+                    fills in any trailing zeros.  */
+                 top |= (top & -top) - 1;
+                 top &= ~(top >> 1);
+                 value = (value ^ top) - top;
+               }
            }
 
          /* If the operand is optional, and the value is zero, don't
@@ -258,7 +266,7 @@ print_insn_powerpc (bfd_vma memaddr,
            (*info->fprintf_func) (info->stream, "%ld", value);
          else
            {
-             if (operand->bits == 3)
+             if (operand->bitm == 7)
                (*info->fprintf_func) (info->stream, "cr%ld", value);
              else
                {
This page took 0.024098 seconds and 4 git commands to generate.