⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppc-opc.c

📁 优龙2410linux2.6.8内核源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* ppc-opc.c -- PowerPC opcode list   Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003   Free Software Foundation, Inc.   Written by Ian Lance Taylor, Cygnus Support   This file is part of GDB, GAS, and the GNU binutils.   GDB, GAS, and the GNU binutils are free software; you can redistribute   them and/or modify them under the terms of the GNU General Public   License as published by the Free Software Foundation; either version   2, or (at your option) any later version.   GDB, GAS, and the GNU binutils are distributed in the hope that they   will be useful, but WITHOUT ANY WARRANTY; without even the implied   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See   the GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this file; see the file COPYING.  If not, write to the Free   Software Foundation, 59 Temple Place - Suite 330, Boston, MA   02111-1307, USA.  */#include "nonstdio.h"#include "ppc.h"#define ATTRIBUTE_UNUSED#define _(x)	x/* This file holds the PowerPC opcode table.  The opcode table   includes almost all of the extended instruction mnemonics.  This   permits the disassembler to use them, and simplifies the assembler   logic, at the cost of increasing the table size.  The table is   strictly constant data, so the compiler should be able to put it in   the .text section.   This file also holds the operand table.  All knowledge about   inserting operands into instructions and vice-versa is kept in this   file.  *//* Local insertion and extraction functions.  */static unsigned long insert_bat (unsigned long, long, int, const char **);static long extract_bat (unsigned long, int, int *);static unsigned long insert_bba (unsigned long, long, int, const char **);static long extract_bba (unsigned long, int, int *);static unsigned long insert_bd (unsigned long, long, int, const char **);static long extract_bd (unsigned long, int, int *);static unsigned long insert_bdm (unsigned long, long, int, const char **);static long extract_bdm (unsigned long, int, int *);static unsigned long insert_bdp (unsigned long, long, int, const char **);static long extract_bdp (unsigned long, int, int *);static unsigned long insert_bo (unsigned long, long, int, const char **);static long extract_bo (unsigned long, int, int *);static unsigned long insert_boe (unsigned long, long, int, const char **);static long extract_boe (unsigned long, int, int *);static unsigned long insert_dq (unsigned long, long, int, const char **);static long extract_dq (unsigned long, int, int *);static unsigned long insert_ds (unsigned long, long, int, const char **);static long extract_ds (unsigned long, int, int *);static unsigned long insert_de (unsigned long, long, int, const char **);static long extract_de (unsigned long, int, int *);static unsigned long insert_des (unsigned long, long, int, const char **);static long extract_des (unsigned long, int, int *);static unsigned long insert_fxm (unsigned long, long, int, const char **);static long extract_fxm (unsigned long, int, int *);static unsigned long insert_li (unsigned long, long, int, const char **);static long extract_li (unsigned long, int, int *);static unsigned long insert_mbe (unsigned long, long, int, const char **);static long extract_mbe (unsigned long, int, int *);static unsigned long insert_mb6 (unsigned long, long, int, const char **);static long extract_mb6 (unsigned long, int, int *);static unsigned long insert_nb (unsigned long, long, int, const char **);static long extract_nb (unsigned long, int, int *);static unsigned long insert_nsi (unsigned long, long, int, const char **);static long extract_nsi (unsigned long, int, int *);static unsigned long insert_ral (unsigned long, long, int, const char **);static unsigned long insert_ram (unsigned long, long, int, const char **);static unsigned long insert_raq (unsigned long, long, int, const char **);static unsigned long insert_ras (unsigned long, long, int, const char **);static unsigned long insert_rbs (unsigned long, long, int, const char **);static long extract_rbs (unsigned long, int, int *);static unsigned long insert_rsq (unsigned long, long, int, const char **);static unsigned long insert_rtq (unsigned long, long, int, const char **);static unsigned long insert_sh6 (unsigned long, long, int, const char **);static long extract_sh6 (unsigned long, int, int *);static unsigned long insert_spr (unsigned long, long, int, const char **);static long extract_spr (unsigned long, int, int *);static unsigned long insert_tbr (unsigned long, long, int, const char **);static long extract_tbr (unsigned long, int, int *);static unsigned long insert_ev2 (unsigned long, long, int, const char **);static long extract_ev2 (unsigned long, int, int *);static unsigned long insert_ev4 (unsigned long, long, int, const char **);static long extract_ev4 (unsigned long, int, int *);static unsigned long insert_ev8 (unsigned long, long, int, const char **);static long extract_ev8 (unsigned long, int, int *);/* The operands table.   The fields are bits, shift, insert, extract, flags.   We used to put parens around the various additions, like the one   for BA just below.  However, that caused trouble with feeble   compilers with a limit on depth of a parenthesized expression, like   (reportedly) the compiler in Microsoft Developer Studio 5.  So we   omit the parens, since the macros are never used in a context where   the addition will be ambiguous.  */const struct powerpc_operand powerpc_operands[] ={  /* The zero index is used to indicate the end of the list of     operands.  */#define UNUSED 0  { 0, 0, 0, 0, 0 },  /* The BA field in an XL form instruction.  */#define BA UNUSED + 1#define BA_MASK (0x1f << 16)  { 5, 16, 0, 0, PPC_OPERAND_CR },  /* The BA field in an XL form instruction when it must be the same     as the BT field in the same instruction.  */#define BAT BA + 1  { 5, 16, insert_bat, extract_bat, PPC_OPERAND_FAKE },  /* The BB field in an XL form instruction.  */#define BB BAT + 1#define BB_MASK (0x1f << 11)  { 5, 11, 0, 0, PPC_OPERAND_CR },  /* The BB field in an XL form instruction when it must be the same     as the BA field in the same instruction.  */#define BBA BB + 1  { 5, 11, insert_bba, extract_bba, PPC_OPERAND_FAKE },  /* The BD field in a B form instruction.  The lower two bits are     forced to zero.  */#define BD BBA + 1  { 16, 0, insert_bd, extract_bd, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },  /* The BD field in a B form instruction when absolute addressing is     used.  */#define BDA BD + 1  { 16, 0, insert_bd, extract_bd, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },  /* The BD field in a B form instruction when the - modifier is used.     This sets the y bit of the BO field appropriately.  */#define BDM BDA + 1  { 16, 0, insert_bdm, extract_bdm,      PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },  /* The BD field in a B form instruction when the - modifier is used     and absolute address is used.  */#define BDMA BDM + 1  { 16, 0, insert_bdm, extract_bdm,      PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },  /* The BD field in a B form instruction when the + modifier is used.     This sets the y bit of the BO field appropriately.  */#define BDP BDMA + 1  { 16, 0, insert_bdp, extract_bdp,      PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },  /* The BD field in a B form instruction when the + modifier is used     and absolute addressing is used.  */#define BDPA BDP + 1  { 16, 0, insert_bdp, extract_bdp,      PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },  /* The BF field in an X or XL form instruction.  */#define BF BDPA + 1  { 3, 23, 0, 0, PPC_OPERAND_CR },  /* An optional BF field.  This is used for comparison instructions,     in which an omitted BF field is taken as zero.  */#define OBF BF + 1  { 3, 23, 0, 0, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },  /* The BFA field in an X or XL form instruction.  */#define BFA OBF + 1  { 3, 18, 0, 0, PPC_OPERAND_CR },  /* The BI field in a B form or XL form instruction.  */#define BI BFA + 1#define BI_MASK (0x1f << 16)  { 5, 16, 0, 0, PPC_OPERAND_CR },  /* The BO field in a B form instruction.  Certain values are     illegal.  */#define BO BI + 1#define BO_MASK (0x1f << 21)  { 5, 21, insert_bo, extract_bo, 0 },  /* The BO field in a B form instruction when the + or - modifier is     used.  This is like the BO field, but it must be even.  */#define BOE BO + 1  { 5, 21, insert_boe, extract_boe, 0 },  /* The BT field in an X or XL form instruction.  */#define BT BOE + 1  { 5, 21, 0, 0, PPC_OPERAND_CR },  /* The condition register number portion of the BI field in a B form     or XL form instruction.  This is used for the extended     conditional branch mnemonics, which set the lower two bits of the     BI field.  This field is optional.  */#define CR BT + 1  { 3, 18, 0, 0, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },  /* The CRB field in an X form instruction.  */#define CRB CR + 1  { 5, 6, 0, 0, 0 },  /* The CRFD field in an X form instruction.  */#define CRFD CRB + 1  { 3, 23, 0, 0, PPC_OPERAND_CR },  /* The CRFS field in an X form instruction.  */#define CRFS CRFD + 1  { 3, 0, 0, 0, PPC_OPERAND_CR },  /* The CT field in an X form instruction.  */#define CT CRFS + 1  { 5, 21, 0, 0, PPC_OPERAND_OPTIONAL },  /* The D field in a D form instruction.  This is a displacement off     a register, and implies that the next operand is a register in     parentheses.  */#define D CT + 1  { 16, 0, 0, 0, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },  /* The DE field in a DE form instruction.  This is like D, but is 12     bits only.  */#define DE D + 1  { 14, 0, insert_de, extract_de, PPC_OPERAND_PARENS },  /* The DES field in a DES form instruction.  This is like DS, but is 14     bits only (12 stored.)  */#define DES DE + 1  { 14, 0, insert_des, extract_des, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },  /* The DQ field in a DQ form instruction.  This is like D, but the     lower four bits are forced to zero. */#define DQ DES + 1  { 16, 0, insert_dq, extract_dq,      PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DQ },  /* The DS field in a DS form instruction.  This is like D, but the     lower two bits are forced to zero.  */#define DS DQ + 1  { 16, 0, insert_ds, extract_ds,      PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DS },  /* The E field in a wrteei instruction.  */#define E DS + 1  { 1, 15, 0, 0, 0 },  /* The FL1 field in a POWER SC form instruction.  */#define FL1 E + 1  { 4, 12, 0, 0, 0 },  /* The FL2 field in a POWER SC form instruction.  */#define FL2 FL1 + 1  { 3, 2, 0, 0, 0 },  /* The FLM field in an XFL form instruction.  */#define FLM FL2 + 1  { 8, 17, 0, 0, 0 },  /* The FRA field in an X or A form instruction.  */#define FRA FLM + 1#define FRA_MASK (0x1f << 16)  { 5, 16, 0, 0, PPC_OPERAND_FPR },  /* The FRB field in an X or A form instruction.  */#define FRB FRA + 1#define FRB_MASK (0x1f << 11)  { 5, 11, 0, 0, PPC_OPERAND_FPR },  /* The FRC field in an A form instruction.  */#define FRC FRB + 1#define FRC_MASK (0x1f << 6)  { 5, 6, 0, 0, PPC_OPERAND_FPR },  /* The FRS field in an X form instruction or the FRT field in a D, X     or A form instruction.  */#define FRS FRC + 1#define FRT FRS  { 5, 21, 0, 0, PPC_OPERAND_FPR },  /* The FXM field in an XFX instruction.  */#define FXM FRS + 1#define FXM_MASK (0xff << 12)  { 8, 12, insert_fxm, extract_fxm, 0 },  /* Power4 version for mfcr.  */#define FXM4 FXM + 1  { 8, 12, insert_fxm, extract_fxm, PPC_OPERAND_OPTIONAL },  /* The L field in a D or X form instruction.  */#define L FXM4 + 1  { 1, 21, 0, 0, PPC_OPERAND_OPTIONAL },  /* The LEV field in a POWER SC form instruction.  */#define LEV L + 1  { 7, 5, 0, 0, 0 },  /* The LI field in an I form instruction.  The lower two bits are     forced to zero.  */#define LI LEV + 1  { 26, 0, insert_li, extract_li, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },  /* The LI field in an I form instruction when used as an absolute     address.  */#define LIA LI + 1  { 26, 0, insert_li, extract_li, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },  /* The LS field in an X (sync) form instruction.  */#define LS LIA + 1  { 2, 21, 0, 0, PPC_OPERAND_OPTIONAL },  /* The MB field in an M form instruction.  */#define MB LS + 1#define MB_MASK (0x1f << 6)  { 5, 6, 0, 0, 0 },  /* The ME field in an M form instruction.  */#define ME MB + 1#define ME_MASK (0x1f << 1)  { 5, 1, 0, 0, 0 },  /* The MB and ME fields in an M form instruction expressed a single     operand which is a bitmask indicating which bits to select.  This     is a two operand form using PPC_OPERAND_NEXT.  See the     description in opcode/ppc.h for what this means.  */#define MBE ME + 1  { 5, 6, 0, 0, PPC_OPERAND_OPTIONAL | PPC_OPERAND_NEXT },  { 32, 0, insert_mbe, extract_mbe, 0 },  /* The MB or ME field in an MD or MDS form instruction.  The high     bit is wrapped to the low end.  */#define MB6 MBE + 2#define ME6 MB6#define MB6_MASK (0x3f << 5)  { 6, 5, insert_mb6, extract_mb6, 0 },  /* The MO field in an mbar instruction.  */#define MO MB6 + 1  { 5, 21, 0, 0, 0 },  /* The NB field in an X form instruction.  The value 32 is stored as     0.  */#define NB MO + 1  { 6, 11, insert_nb, extract_nb, 0 },  /* The NSI field in a D form instruction.  This is the same as the     SI field, only negated.  */#define NSI NB + 1  { 16, 0, insert_nsi, extract_nsi,      PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED },  /* The RA field in an D, DS, DQ, X, XO, M, or MDS form instruction.  */#define RA NSI + 1#define RA_MASK (0x1f << 16)  { 5, 16, 0, 0, PPC_OPERAND_GPR },  /* The RA field in the DQ form lq instruction, which has special     value restrictions.  */#define RAQ RA + 1  { 5, 16, insert_raq, 0, PPC_OPERAND_GPR },  /* The RA field in a D or X form instruction which is an updating     load, which means that the RA field may not be zero and may not     equal the RT field.  */#define RAL RAQ + 1  { 5, 16, insert_ral, 0, PPC_OPERAND_GPR },  /* The RA field in an lmw instruction, which has special value     restrictions.  */#define RAM RAL + 1  { 5, 16, insert_ram, 0, PPC_OPERAND_GPR },  /* The RA field in a D or X form instruction which is an updating     store or an updating floating point load, which means that the RA     field may not be zero.  */#define RAS RAM + 1  { 5, 16, insert_ras, 0, PPC_OPERAND_GPR },  /* The RB field in an X, XO, M, or MDS form instruction.  */#define RB RAS + 1#define RB_MASK (0x1f << 11)  { 5, 11, 0, 0, PPC_OPERAND_GPR },  /* The RB field in an X form instruction when it must be the same as     the RS field in the instruction.  This is used for extended     mnemonics like mr.  */#define RBS RB + 1  { 5, 1, insert_rbs, extract_rbs, PPC_OPERAND_FAKE },  /* The RS field in a D, DS, X, XFX, XS, M, MD or MDS form     instruction or the RT field in a D, DS, X, XFX or XO form

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -