📄 ppc-opc.c
字号:
{ 5, 11, NULL, NULL, 0 }, /* The SH field in an MD form instruction. This is split. */#define SH6 (48)#define SH6_MASK ((0x1f << 11) | (1 << 1)) { 6, 1, insert_sh6, extract_sh6, 0 }, /* The SI field in a D form instruction. */#define SI (49) { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED }, /* The SI field in a D form instruction when we accept a wide range of positive values. */#define SISIGNOPT (50) { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT }, /* The SPR field in an XFX form instruction. This is flipped--the lower 5 bits are stored in the upper 5 and vice- versa. */#define SPR (51)#define SPR_MASK (0x3ff << 11) { 10, 11, insert_spr, extract_spr, 0 }, /* The BAT index number in an XFX form m[ft]ibat[lu] instruction. */#define SPRBAT (52)#define SPRBAT_MASK (0x3 << 17) { 2, 17, NULL, NULL, 0 }, /* The SPRG register number in an XFX form m[ft]sprg instruction. */#define SPRG (53)#define SPRG_MASK (0x3 << 16) { 2, 16, NULL, NULL, 0 }, /* The SR field in an X form instruction. */#define SR (54) { 4, 16, NULL, NULL, 0 }, /* The SV field in a POWER SC form instruction. */#define SV (55) { 14, 2, NULL, NULL, 0 }, /* The TBR field in an XFX form instruction. This is like the SPR field, but it is optional. */#define TBR (56) { 10, 11, insert_tbr, extract_tbr, PPC_OPERAND_OPTIONAL }, /* The TO field in a D or X form instruction. */#define TO (57)#define TO_MASK (0x1f << 21) { 5, 21, NULL, NULL, 0 }, /* The U field in an X form instruction. */#define U (58) { 4, 12, NULL, NULL, 0 }, /* The UI field in a D form instruction. */#define UI (59) { 16, 0, NULL, NULL, 0 },};/* The functions used to insert and extract complicated operands. *//* The BA field in an XL form instruction when it must be the same as the BT field in the same instruction. This operand is marked FAKE. The insertion function just copies the BT field into the BA field, and the extraction function just checks that the fields are the same. *//*ARGSUSED*/static unsigned longinsert_bat(unsigned long insn, long value, const char **errmsg){ return insn | (((insn >> 21) & 0x1f) << 16);}static longextract_bat(unsigned long insn, int *invalid){ if (invalid != (int *) NULL && ((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f)) *invalid = 1; return 0;}/* The BB field in an XL form instruction when it must be the same as the BA field in the same instruction. This operand is marked FAKE. The insertion function just copies the BA field into the BB field, and the extraction function just checks that the fields are the same. *//*ARGSUSED*/static unsigned longinsert_bba(unsigned long insn, long value, const char **errmsg){ return insn | (((insn >> 16) & 0x1f) << 11);}static longextract_bba(unsigned long insn, int *invalid){ if (invalid != (int *) NULL && ((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f)) *invalid = 1; return 0;}/* The BD field in a B form instruction. The lower two bits are forced to zero. *//*ARGSUSED*/static unsigned longinsert_bd(unsigned long insn, long value, const char **errmsg){ return insn | (value & 0xfffc);}/*ARGSUSED*/static longextract_bd(unsigned long insn, int *invalid){ if ((insn & 0x8000) != 0) return (insn & 0xfffc) - 0x10000; else return insn & 0xfffc;}/* The BD field in a B form instruction when the - modifier is used. This modifier means that the branch is not expected to be taken. We must set the y bit of the BO field to 1 if the offset is negative. When extracting, we require that the y bit be 1 and that the offset be positive, since if the y bit is 0 we just want to print the normal form of the instruction. *//*ARGSUSED*/static unsigned longinsert_bdm(unsigned long insn, long value, const char **errmsg){ if ((value & 0x8000) != 0) insn |= 1 << 21; return insn | (value & 0xfffc);}static longextract_bdm(unsigned long insn, int *invalid){ if (invalid != (int *) NULL && ((insn & (1 << 21)) == 0 || (insn & (1 << 15)) == 0)) *invalid = 1; if ((insn & 0x8000) != 0) return (insn & 0xfffc) - 0x10000; else return insn & 0xfffc;}/* The BD field in a B form instruction when the + modifier is used. This is like BDM, above, except that the branch is expected to be taken. *//*ARGSUSED*/static unsigned longinsert_bdp(unsigned long insn, long value, const char **errmsg){ if ((value & 0x8000) == 0) insn |= 1 << 21; return insn | (value & 0xfffc);}static longextract_bdp(unsigned long insn, int *invalid){ if (invalid != (int *) NULL && ((insn & (1 << 21)) == 0 || (insn & (1 << 15)) != 0)) *invalid = 1; if ((insn & 0x8000) != 0) return (insn & 0xfffc) - 0x10000; else return insn & 0xfffc;}/* Check for legal values of a BO field. */static intvalid_bo (long value){ /* Certain encodings have bits that are required to be zero. These are (z must be zero, y may be anything): 001zy 011zy 1z00y 1z01y 1z1zz */ switch (value & 0x14) { default: case 0: return 1; case 0x4: return (value & 0x2) == 0; case 0x10: return (value & 0x8) == 0; case 0x14: return value == 0x14; }}/* The BO field in a B form instruction. Warn about attempts to set the field to an illegal value. */static unsigned longinsert_bo(unsigned long insn, long value, const char **errmsg){ if (errmsg != (const char **) NULL && ! valid_bo (value)) *errmsg = "invalid conditional option"; return insn | ((value & 0x1f) << 21);}static longextract_bo(unsigned long insn, int *invalid){ long value; value = (insn >> 21) & 0x1f; if (invalid != (int *) NULL && ! valid_bo (value)) *invalid = 1; return value;}/* 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. When extracting it, we force it to be even. */static unsigned longinsert_boe(unsigned long insn, long value, const char **errmsg){ if (errmsg != (const char **) NULL) { if (! valid_bo (value)) *errmsg = "invalid conditional option"; else if ((value & 1) != 0) *errmsg = "attempt to set y bit when using + or - modifier"; } return insn | ((value & 0x1f) << 21);}static longextract_boe(unsigned long insn, int *invalid){ long value; value = (insn >> 21) & 0x1f; if (invalid != (int *) NULL && ! valid_bo (value)) *invalid = 1; return value & 0x1e;}/* The DS field in a DS form instruction. This is like D, but the lower two bits are forced to zero. *//*ARGSUSED*/static unsigned longinsert_ds(unsigned long insn, long value, const char **errmsg){ return insn | (value & 0xfffc);}/*ARGSUSED*/static longextract_ds(unsigned long insn, int *invalid){ if ((insn & 0x8000) != 0) return (insn & 0xfffc) - 0x10000; else return insn & 0xfffc;}/* The LI field in an I form instruction. The lower two bits are forced to zero. *//*ARGSUSED*/static unsigned longinsert_li(unsigned long insn, long value, const char **errmsg){ return insn | (value & 0x3fffffc);}/*ARGSUSED*/static longextract_li(unsigned long insn, int *invalid){ if ((insn & 0x2000000) != 0) return (insn & 0x3fffffc) - 0x4000000; else return insn & 0x3fffffc;}/* The MB and ME fields in an M form instruction expressed as a single operand which is itself a bitmask. The extraction function always marks it as invalid, since we never want to recognize an instruction which uses a field of this type. */static unsigned longinsert_mbe(unsigned long insn, long value, const char **errmsg){ unsigned long uval; int mb, me; uval = value; if (uval == 0) { if (errmsg != (const char **) NULL) *errmsg = "illegal bitmask"; return insn; } me = 31; while ((uval & 1) == 0) { uval >>= 1; --me; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -