// SPDX-License-Identifier: GPL-2.0-or-later /* ppc-dis.c -- Disassemble PowerPC instructions Copyright (C) 1994-2016 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support
This file is part of GDB, GAS, and the GNU binutils.
/* This file provides several disassembler functions, all of which use the disassembler interface defined in dis-asm.h. Several functions are provided because this file handles disassembly for the PowerPC in both big and little endian mode and also for the POWER (RS/6000)
chip. */
/* Extract the operand value from the PowerPC or POWER instruction. */
staticlong
operand_value_powerpc (conststruct powerpc_operand *operand, unsignedlong insn, ppc_cpu_t dialect)
{ long value; int invalid; /* Extract the value from the instruction. */ if (operand->extract)
value = (*operand->extract) (insn, dialect, &invalid); else
{ if (operand->shift >= 0)
value = (insn >> operand->shift) & operand->bitm; else
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 number of zeros. */ unsignedlong 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;
}
}
return value;
}
/* Determine whether the optional operand(s) should be printed. */
opcode_end = powerpc_opcodes + powerpc_num_opcodes; /* Find the first match in the opcode table for this major opcode. */ for (opcode = powerpc_opcodes; opcode < opcode_end; ++opcode)
{ constunsignedchar *opindex; conststruct powerpc_operand *operand; int invalid;
if (opcode != NULL)
{ constunsignedchar *opindex; conststruct powerpc_operand *operand; int need_comma; int need_paren; int skip_optional;
if (opcode->operands[0] != 0)
printf("%-7s ", opcode->name); else
printf("%s", opcode->name);
if (insn_is_short) /* The operands will be fetched out of the 16-bit instruction. */
insn >>= 16;
/* Now extract and print the operands. */
need_comma = 0;
need_paren = 0;
skip_optional = -1; for (opindex = opcode->operands; *opindex != 0; opindex++)
{ long value;
operand = powerpc_operands + *opindex;
/* Operands that are marked FAKE are simply ignored. We already made sure that the extract function considered
the instruction to be valid. */ if ((operand->flags & PPC_OPERAND_FAKE) != 0) continue;
/* If all of the optional operands have the value zero,
then don't print any of them. */ if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0)
{ if (skip_optional < 0)
skip_optional = skip_optional_operands (opindex, insn,
dialect); if (skip_optional) continue;
}
value = operand_value_powerpc (operand, insn, dialect);
/* We have found and printed an instruction.
If it was a short VLE instruction we have more to do. */ if (insn_is_short)
{
memaddr += 2; return 2;
} else /* Otherwise, return. */ return 4;
}
/* We could not find a match. */
printf(".long 0x%lx", insn);
return 4;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.27 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.