1 /* mips.h. Mips opcode list for GDB, the GNU debugger.
2 Copyright 1993 Free Software Foundation, Inc.
3 Contributed by Ralph Campbell and OSF
4 Commented and modified by Ian Lance Taylor, Cygnus Support
6 This file is part of GDB, GAS, and the GNU binutils.
8 GDB, GAS, and the GNU binutils are free software; you can redistribute
9 them and/or modify them under the terms of the GNU General Public
10 License as published by the Free Software Foundation; either version
11 1, or (at your option) any later version.
13 GDB, GAS, and the GNU binutils are distributed in the hope that they
14 will be useful, but WITHOUT ANY WARRANTY; without even the implied
15 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
16 the GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this file; see the file COPYING. If not, write to the Free
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* These are bit masks and shift counts to use to access the various
23 fields of an instruction. To retrieve the X field of an
24 instruction, use the expression
25 (i >> OP_SH_X) & OP_MASK_X
26 To set the same field (to j), use
27 i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X)
29 Make sure you use fields that are appropriate for the instruction,
32 The 'i' format uses OP, RS, RT and IMMEDIATE.
34 The 'j' format uses OP and TARGET.
36 The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT.
38 The 'b' format uses OP, RS, RT and DELTA.
40 The floating point 'i' format uses OP, RS, RT and IMMEDIATE.
42 The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT.
44 A breakpoint instruction uses OP, CODE and SPEC (10 bits of the
45 breakpoint instruction are not defined; Kane says the breakpoint
46 code field in BREAK is 20 bits; yet MIPS assemblers and debuggers
49 The syscall instruction uses SYSCALL.
51 The general coprocessor instructions use COPZ. */
53 #define OP_MASK_OP 0x3f
55 #define OP_MASK_RS 0x1f
57 #define OP_MASK_FMT 0x1f
59 #define OP_MASK_CODE 0x3ff
61 #define OP_MASK_RT 0x1f
63 #define OP_MASK_FT 0x1f
65 #define OP_MASK_RD 0x1f
67 #define OP_MASK_FS 0x1f
69 #define OP_MASK_SYSCALL 0xfffff
70 #define OP_SH_SYSCALL 6
71 #define OP_MASK_SHAMT 0x1f
73 #define OP_MASK_FD 0x1f
75 #define OP_MASK_TARGET 0x3ffffff
76 #define OP_SH_TARGET 0
77 #define OP_MASK_COPZ 0x1ffffff
79 #define OP_MASK_IMMEDIATE 0xffff
80 #define OP_SH_IMMEDIATE 0
81 #define OP_MASK_DELTA 0xffff
83 #define OP_MASK_FUNCT 0x3f
85 #define OP_MASK_SPEC 0x3f
88 /* This structure holds information for a particular instruction. */
92 /* The name of the instruction. */
94 /* A string describing the arguments for this instruction. */
96 /* The basic opcode for the instruction. When assembling, this
97 opcode is modified by the arguments to produce the actual opcode
98 that is used. If pinfo is INSN_MACRO, then this is instead the
99 ISA level of the macro (0 or 1 is always supported, 2 is ISA 2,
102 /* If pinfo is not INSN_MACRO, then this is a bit mask for the
103 relevant portions of the opcode when disassembling. If the
104 actual opcode anded with the match field equals the opcode field,
105 then we have found the correct instruction. If pinfo is
106 INSN_MACRO, then this field is the macro identifier. */
108 /* For a macro, this is INSN_MACRO. Otherwise, it is a collection
109 of bits describing the instruction, notably any relevant hazard
114 /* These are the characters which may appears in the args field of an
115 instruction. They appear in the order in which the fields appear
116 when the instruction is used. Commas and parentheses in the args
117 string are ignored when assembling, and written into the output
120 Each of these characters corresponds to a mask field defined above.
122 "<" 5 bit shift amount (OP_*_SHAMT)
123 "a" 26 bit target address (OP_*_TARGET)
124 "b" 5 bit base register (OP_*_RS)
125 "c" 10 bit breakpoint code (OP_*_CODE)
126 "d" 5 bit destination register specifier (OP_*_RD)
127 "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
128 "j" 16 bit signed immediate (OP_*_DELTA)
129 "o" 16 bit signed offset (OP_*_DELTA)
130 "p" 16 bit PC relative branch target address (OP_*_DELTA)
131 "r" 5 bit same register used as both source and target (OP_*_RS)
132 "s" 5 bit source register specifier (OP_*_RS)
133 "t" 5 bit target register (OP_*_RT)
134 "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
135 "v" 5 bit same register used as both source and destination (OP_*_RS)
136 "w" 5 bit same register used as both target and destination (OP_*_RT)
137 "C" 25 bit coprocessor function code (OP_*_COPZ)
138 "B" 20 bit syscall function code (OP_*_SYSCALL)
139 "x" accept and ignore register name
141 Floating point instructions:
142 "D" 5 bit destination register (OP_*_FD)
143 "S" 5 bit fs source 1 register (OP_*_FS)
144 "T" 5 bit ft source 2 register (OP_*_FT)
145 "V" 5 bit same register used as floating source and destination (OP_*_FS)
146 "W" 5 bit same register used as floating target and destination (OP_*_FT)
148 Coprocessor instructions:
149 "E" 5 bit target register (OP_*_RT)
150 "G" 5 bit destination register (OP_*_RD)
153 "A" General 32 bit expression
155 "F" 64 bit floating point constant in .rdata
156 "L" 64 bit floating point constant in .lit8
157 "f" 32 bit floating point constant
158 "l" 32 bit floating point constant in .lit4
161 /* These are the bits which may be set in the pinfo field of an
162 instructions, if it is not equal to INSN_MACRO. */
164 /* Modifies the general purpose register in OP_*_RD. */
165 #define INSN_WRITE_GPR_D 0x00000001
166 /* Modifies the general purpose register in OP_*_RT. */
167 #define INSN_WRITE_GPR_T 0x00000002
168 /* Modifies general purpose register 31. */
169 #define INSN_WRITE_GPR_31 0x00000004
170 /* Modifies the floating point register in OP_*_FD. */
171 #define INSN_WRITE_FPR_D 0x00000008
172 /* Modifies the floating point register in OP_*_FS. */
173 #define INSN_WRITE_FPR_S 0x00000010
174 /* Modifies the floating point register in OP_*_FT. */
175 #define INSN_WRITE_FPR_T 0x00000020
176 /* Reads the general purpose register in OP_*_RS. */
177 #define INSN_READ_GPR_S 0x00000040
178 /* Reads the general purpose register in OP_*_RT. */
179 #define INSN_READ_GPR_T 0x00000080
180 /* Reads the floating point register in OP_*_FS. */
181 #define INSN_READ_FPR_S 0x00000100
182 /* Reads the floating point register in OP_*_FT. */
183 #define INSN_READ_FPR_T 0x00000200
184 /* Modifies coprocessor condition code. */
185 #define INSN_WRITE_COND_CODE 0x00000400
186 /* Reads coprocessor condition code. */
187 #define INSN_READ_COND_CODE 0x00000800
189 #define INSN_TLB 0x00001000
190 /* RFE (return from exception) instruction. */
191 #define INSN_RFE 0x00002000
192 /* Reads coprocessor register other than floating point register. */
193 #define INSN_COP 0x00004000
194 /* Instruction loads value from memory, requiring delay. */
195 #define INSN_LOAD_MEMORY_DELAY 0x00008000
196 /* Instruction loads value from coprocessor, requiring delay. */
197 #define INSN_LOAD_COPROC_DELAY 0x00010000
198 /* Instruction has unconditional branch delay slot. */
199 #define INSN_UNCOND_BRANCH_DELAY 0x00020000
200 /* Instruction has conditional branch delay slot. */
201 #define INSN_COND_BRANCH_DELAY 0x00040000
202 /* Conditional branch likely: if branch not taken, insn nullified. */
203 #define INSN_COND_BRANCH_LIKELY 0x00080000
204 /* Moves to coprocessor register, requiring delay. */
205 #define INSN_COPROC_MOVE_DELAY 0x00100000
206 /* Loads coprocessor register from memory, requiring delay. */
207 #define INSN_COPROC_MEMORY_DELAY 0x00200000
208 /* Reads the HI register. */
209 #define INSN_READ_HI 0x00400000
210 /* Reads the LO register. */
211 #define INSN_READ_LO 0x00800000
212 /* Modifies the HI register. */
213 #define INSN_WRITE_HI 0x01000000
214 /* Modifies the LO register. */
215 #define INSN_WRITE_LO 0x02000000
216 /* Takes a trap (FIXME: why is this interesting?). */
217 #define INSN_TRAP 0x04000000
218 /* MIPS ISA 2 instruction (R6000 or R4000). */
219 #define INSN_ISA2 0x10000000
220 /* MIPS ISA 3 instruction (R4000). */
221 #define INSN_ISA3 0x20000000
223 /* Instruction is actually a macro. It should be ignored by the
224 disassembler, and requires special treatment by the assembler. */
225 #define INSN_MACRO 0xffffffff
227 /* This is a list of macro expanded instructions.
229 * _I appended means immediate
230 * _A appended means address
231 * _AB appended means address with base register
232 * _D appended means 64 bit floating point constant
233 * _S appended means 32 bit floating point constant
431 /* The order of overloaded instructions matters. Label arguments and
432 register arguments look the same. Instructions that can have either
433 for arguments must apear in the correct order in this table for the
434 assembler to pick the right one. In other words, entries with
435 immediate operands must apear after the same instruction with
438 Many instructions are short hand for other instructions (i.e., The
439 jal <register> instruction is short for jalr <register>). */
441 extern const struct mips_opcode mips_opcodes
[];
442 extern const int bfd_mips_num_opcodes
;
443 #define NUMOPCODES bfd_mips_num_opcodes
This page took 0.039233 seconds and 5 git commands to generate.