1*3d8817e4Smiod /* v850.h -- Header file for NEC V850 opcode table 2*3d8817e4Smiod Copyright 1996, 1997, 2001, 2003 Free Software Foundation, Inc. 3*3d8817e4Smiod Written by J.T. Conklin, Cygnus Support 4*3d8817e4Smiod 5*3d8817e4Smiod This file is part of GDB, GAS, and the GNU binutils. 6*3d8817e4Smiod 7*3d8817e4Smiod GDB, GAS, and the GNU binutils are free software; you can redistribute 8*3d8817e4Smiod them and/or modify them under the terms of the GNU General Public 9*3d8817e4Smiod License as published by the Free Software Foundation; either version 10*3d8817e4Smiod 1, or (at your option) any later version. 11*3d8817e4Smiod 12*3d8817e4Smiod GDB, GAS, and the GNU binutils are distributed in the hope that they 13*3d8817e4Smiod will be useful, but WITHOUT ANY WARRANTY; without even the implied 14*3d8817e4Smiod warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 15*3d8817e4Smiod the GNU General Public License for more details. 16*3d8817e4Smiod 17*3d8817e4Smiod You should have received a copy of the GNU General Public License 18*3d8817e4Smiod along with this file; see the file COPYING. If not, write to the Free 19*3d8817e4Smiod Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 20*3d8817e4Smiod 21*3d8817e4Smiod #ifndef V850_H 22*3d8817e4Smiod #define V850_H 23*3d8817e4Smiod 24*3d8817e4Smiod /* The opcode table is an array of struct v850_opcode. */ 25*3d8817e4Smiod 26*3d8817e4Smiod struct v850_opcode 27*3d8817e4Smiod { 28*3d8817e4Smiod /* The opcode name. */ 29*3d8817e4Smiod const char *name; 30*3d8817e4Smiod 31*3d8817e4Smiod /* The opcode itself. Those bits which will be filled in with 32*3d8817e4Smiod operands are zeroes. */ 33*3d8817e4Smiod unsigned long opcode; 34*3d8817e4Smiod 35*3d8817e4Smiod /* The opcode mask. This is used by the disassembler. This is a 36*3d8817e4Smiod mask containing ones indicating those bits which must match the 37*3d8817e4Smiod opcode field, and zeroes indicating those bits which need not 38*3d8817e4Smiod match (and are presumably filled in by operands). */ 39*3d8817e4Smiod unsigned long mask; 40*3d8817e4Smiod 41*3d8817e4Smiod /* An array of operand codes. Each code is an index into the 42*3d8817e4Smiod operand table. They appear in the order which the operands must 43*3d8817e4Smiod appear in assembly code, and are terminated by a zero. */ 44*3d8817e4Smiod unsigned char operands[8]; 45*3d8817e4Smiod 46*3d8817e4Smiod /* Which (if any) operand is a memory operand. */ 47*3d8817e4Smiod unsigned int memop; 48*3d8817e4Smiod 49*3d8817e4Smiod /* Target processor(s). A bit field of processors which support 50*3d8817e4Smiod this instruction. Note a bit field is used as some instructions 51*3d8817e4Smiod are available on multiple, different processor types, whereas 52*3d8817e4Smiod other instructions are only available on one specific type. */ 53*3d8817e4Smiod unsigned int processors; 54*3d8817e4Smiod }; 55*3d8817e4Smiod 56*3d8817e4Smiod /* Values for the processors field in the v850_opcode structure. */ 57*3d8817e4Smiod #define PROCESSOR_V850 (1 << 0) /* Just the V850. */ 58*3d8817e4Smiod #define PROCESSOR_ALL -1 /* Any processor. */ 59*3d8817e4Smiod #define PROCESSOR_V850E (1 << 1) /* Just the V850E. */ 60*3d8817e4Smiod #define PROCESSOR_NOT_V850 (~ PROCESSOR_V850) /* Any processor except the V850. */ 61*3d8817e4Smiod #define PROCESSOR_V850EA (1 << 2) /* Just the V850EA. */ 62*3d8817e4Smiod #define PROCESSOR_V850E1 (1 << 3) /* Just the V850E1. */ 63*3d8817e4Smiod 64*3d8817e4Smiod /* The table itself is sorted by major opcode number, and is otherwise 65*3d8817e4Smiod in the order in which the disassembler should consider 66*3d8817e4Smiod instructions. */ 67*3d8817e4Smiod extern const struct v850_opcode v850_opcodes[]; 68*3d8817e4Smiod extern const int v850_num_opcodes; 69*3d8817e4Smiod 70*3d8817e4Smiod 71*3d8817e4Smiod /* The operands table is an array of struct v850_operand. */ 72*3d8817e4Smiod 73*3d8817e4Smiod struct v850_operand 74*3d8817e4Smiod { 75*3d8817e4Smiod /* The number of bits in the operand. */ 76*3d8817e4Smiod /* If this value is -1 then the operand's bits are in a discontinous distribution in the instruction. */ 77*3d8817e4Smiod int bits; 78*3d8817e4Smiod 79*3d8817e4Smiod /* (bits >= 0): How far the operand is left shifted in the instruction. */ 80*3d8817e4Smiod /* (bits == -1): Bit mask of the bits in the operand. */ 81*3d8817e4Smiod int shift; 82*3d8817e4Smiod 83*3d8817e4Smiod /* Insertion function. This is used by the assembler. To insert an 84*3d8817e4Smiod operand value into an instruction, check this field. 85*3d8817e4Smiod 86*3d8817e4Smiod If it is NULL, execute 87*3d8817e4Smiod i |= (op & ((1 << o->bits) - 1)) << o->shift; 88*3d8817e4Smiod (i is the instruction which we are filling in, o is a pointer to 89*3d8817e4Smiod this structure, and op is the opcode value; this assumes twos 90*3d8817e4Smiod complement arithmetic). 91*3d8817e4Smiod 92*3d8817e4Smiod If this field is not NULL, then simply call it with the 93*3d8817e4Smiod instruction and the operand value. It will return the new value 94*3d8817e4Smiod of the instruction. If the ERRMSG argument is not NULL, then if 95*3d8817e4Smiod the operand value is illegal, *ERRMSG will be set to a warning 96*3d8817e4Smiod string (the operand will be inserted in any case). If the 97*3d8817e4Smiod operand value is legal, *ERRMSG will be unchanged (most operands 98*3d8817e4Smiod can accept any value). */ 99*3d8817e4Smiod unsigned long (* insert) 100*3d8817e4Smiod (unsigned long instruction, long op, const char ** errmsg); 101*3d8817e4Smiod 102*3d8817e4Smiod /* Extraction function. This is used by the disassembler. To 103*3d8817e4Smiod extract this operand type from an instruction, check this field. 104*3d8817e4Smiod 105*3d8817e4Smiod If it is NULL, compute 106*3d8817e4Smiod op = o->bits == -1 ? ((i) & o->shift) : ((i) >> o->shift) & ((1 << o->bits) - 1); 107*3d8817e4Smiod if (o->flags & V850_OPERAND_SIGNED) 108*3d8817e4Smiod op = (op << (32 - o->bits)) >> (32 - o->bits); 109*3d8817e4Smiod (i is the instruction, o is a pointer to this structure, and op 110*3d8817e4Smiod is the result; this assumes twos complement arithmetic). 111*3d8817e4Smiod 112*3d8817e4Smiod If this field is not NULL, then simply call it with the 113*3d8817e4Smiod instruction value. It will return the value of the operand. If 114*3d8817e4Smiod the INVALID argument is not NULL, *INVALID will be set to 115*3d8817e4Smiod non-zero if this operand type can not actually be extracted from 116*3d8817e4Smiod this operand (i.e., the instruction does not match). If the 117*3d8817e4Smiod operand is valid, *INVALID will not be changed. */ 118*3d8817e4Smiod unsigned long (* extract) (unsigned long instruction, int * invalid); 119*3d8817e4Smiod 120*3d8817e4Smiod /* One bit syntax flags. */ 121*3d8817e4Smiod int flags; 122*3d8817e4Smiod }; 123*3d8817e4Smiod 124*3d8817e4Smiod /* Elements in the table are retrieved by indexing with values from 125*3d8817e4Smiod the operands field of the v850_opcodes table. */ 126*3d8817e4Smiod 127*3d8817e4Smiod extern const struct v850_operand v850_operands[]; 128*3d8817e4Smiod 129*3d8817e4Smiod /* Values defined for the flags field of a struct v850_operand. */ 130*3d8817e4Smiod 131*3d8817e4Smiod /* This operand names a general purpose register */ 132*3d8817e4Smiod #define V850_OPERAND_REG 0x01 133*3d8817e4Smiod 134*3d8817e4Smiod /* This operand names a system register */ 135*3d8817e4Smiod #define V850_OPERAND_SRG 0x02 136*3d8817e4Smiod 137*3d8817e4Smiod /* This operand names a condition code used in the setf instruction */ 138*3d8817e4Smiod #define V850_OPERAND_CC 0x04 139*3d8817e4Smiod 140*3d8817e4Smiod /* This operand takes signed values */ 141*3d8817e4Smiod #define V850_OPERAND_SIGNED 0x08 142*3d8817e4Smiod 143*3d8817e4Smiod /* This operand is the ep register. */ 144*3d8817e4Smiod #define V850_OPERAND_EP 0x10 145*3d8817e4Smiod 146*3d8817e4Smiod /* This operand is a PC displacement */ 147*3d8817e4Smiod #define V850_OPERAND_DISP 0x20 148*3d8817e4Smiod 149*3d8817e4Smiod /* This is a relaxable operand. Only used for D9->D22 branch relaxing 150*3d8817e4Smiod right now. We may need others in the future (or maybe handle them like 151*3d8817e4Smiod promoted operands on the mn10300?) */ 152*3d8817e4Smiod #define V850_OPERAND_RELAX 0x40 153*3d8817e4Smiod 154*3d8817e4Smiod /* The register specified must not be r0 */ 155*3d8817e4Smiod #define V850_NOT_R0 0x80 156*3d8817e4Smiod 157*3d8817e4Smiod /* push/pop type instruction, V850E specific. */ 158*3d8817e4Smiod #define V850E_PUSH_POP 0x100 159*3d8817e4Smiod 160*3d8817e4Smiod /* 16 bit immediate follows instruction, V850E specific. */ 161*3d8817e4Smiod #define V850E_IMMEDIATE16 0x200 162*3d8817e4Smiod 163*3d8817e4Smiod /* 32 bit immediate follows instruction, V850E specific. */ 164*3d8817e4Smiod #define V850E_IMMEDIATE32 0x400 165*3d8817e4Smiod 166*3d8817e4Smiod #endif /* V850_H */ 167