Rizin
unix-like reverse engineering framework and cli tools
nios2-opc.c
Go to the documentation of this file.
1 /* Altera Nios II opcode list.
2  Copyright (C) 2012, 2013 Free Software Foundation, Inc.
3  Contributed by Nigel Gray (ngray@altera.com).
4  Contributed by Mentor Graphics, Inc.
5 
6  This file is part of the GNU opcodes library.
7 
8  This library is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3, or (at your option)
11  any later version.
12 
13  It is distributed in the hope that it will be useful, but WITHOUT
14  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16  License for more details.
17 
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
20  Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
21  MA 02110-1301, USA. */
22 
23 #include "sysdep.h"
24 #include <stdio.h>
25 #include "opcode/nios2.h"
26 
27 /* Register string table */
28 
29 const struct nios2_reg nios2_builtin_regs[] = {
30  /* Standard register names. */
31  {"zero", 0},
32  {"at", 1}, /* assembler temporary */
33  {"r2", 2},
34  {"r3", 3},
35  {"r4", 4},
36  {"r5", 5},
37  {"r6", 6},
38  {"r7", 7},
39  {"r8", 8},
40  {"r9", 9},
41  {"r10", 10},
42  {"r11", 11},
43  {"r12", 12},
44  {"r13", 13},
45  {"r14", 14},
46  {"r15", 15},
47  {"r16", 16},
48  {"r17", 17},
49  {"r18", 18},
50  {"r19", 19},
51  {"r20", 20},
52  {"r21", 21},
53  {"r22", 22},
54  {"r23", 23},
55  {"et", 24},
56  {"bt", 25},
57  {"gp", 26}, /* global pointer */
58  {"sp", 27}, /* stack pointer */
59  {"fp", 28}, /* frame pointer */
60  {"ea", 29}, /* exception return address */
61  {"ba", 30}, /* breakpoint return address */
62  {"ra", 31}, /* return address */
63 
64  /* Alternative names for special registers. */
65  {"r0", 0},
66  {"r1", 1},
67  {"r24", 24},
68  {"r25", 25},
69  {"r26", 26},
70  {"r27", 27},
71  {"r28", 28},
72  {"r29", 29},
73  {"r30", 30},
74  {"sstatus", 30},
75  {"r31", 31},
76 
77  /* Control register names. */
78  {"status", 0},
79  {"estatus", 1},
80  {"bstatus", 2},
81  {"ienable", 3},
82  {"ipending", 4},
83  {"cpuid", 5},
84  {"ctl6", 6},
85  {"exception", 7},
86  {"pteaddr", 8},
87  {"tlbacc", 9},
88  {"tlbmisc", 10},
89  {"eccinj", 11},
90  {"badaddr", 12},
91  {"config", 13},
92  {"mpubase", 14},
93  {"mpuacc", 15},
94  {"ctl16", 16},
95  {"ctl17", 17},
96  {"ctl18", 18},
97  {"ctl19", 19},
98  {"ctl20", 20},
99  {"ctl21", 21},
100  {"ctl22", 22},
101  {"ctl23", 23},
102  {"ctl24", 24},
103  {"ctl25", 25},
104  {"ctl26", 26},
105  {"ctl27", 27},
106  {"ctl28", 28},
107  {"ctl29", 29},
108  {"ctl30", 30},
109  {"ctl31", 31},
110 
111  /* Alternative names for special control registers. */
112  {"ctl0", 0},
113  {"ctl1", 1},
114  {"ctl2", 2},
115  {"ctl3", 3},
116  {"ctl4", 4},
117  {"ctl5", 5},
118  {"ctl7", 7},
119  {"ctl8", 8},
120  {"ctl9", 9},
121  {"ctl10", 10},
122  {"ctl11", 11},
123  {"ctl12", 12},
124  {"ctl13", 13},
125  {"ctl14", 14},
126  {"ctl15", 15},
127 
128  /* Coprocessor register names. */
129  {"c0", 0},
130  {"c1", 1},
131  {"c2", 2},
132  {"c3", 3},
133  {"c4", 4},
134  {"c5", 5},
135  {"c6", 6},
136  {"c7", 7},
137  {"c8", 8},
138  {"c9", 9},
139  {"c10", 10},
140  {"c11", 11},
141  {"c12", 12},
142  {"c13", 13},
143  {"c14", 14},
144  {"c15", 15},
145  {"c16", 16},
146  {"c17", 17},
147  {"c18", 18},
148  {"c19", 19},
149  {"c20", 20},
150  {"c21", 21},
151  {"c22", 22},
152  {"c23", 23},
153  {"c24", 24},
154  {"c25", 25},
155  {"c26", 26},
156  {"c27", 27},
157  {"c28", 28},
158  {"c29", 29},
159  {"c30", 30},
160  {"c31", 31},
161 };
162 
163 #define NIOS2_NUM_REGS \
164  ((sizeof nios2_builtin_regs) / (sizeof (nios2_builtin_regs[0])))
166 
167 /* This is not const in order to allow for dynamic extensions to the
168  built-in instruction set. */
171 #undef NIOS2_NUM_REGS
172 
173 /* This is the opcode table used by the Nios II GNU as, disassembler
174  and GDB. */
175 const struct nios2_opcode nios2_builtin_opcodes[] =
176 {
177  /* { name, args, args_test, num_args,
178  match, mask, pinfo, overflow_msg } */
179  {"add", "d,s,t", "d,s,t,E", 3,
181  {"addi", "t,s,i", "t,s,i,E", 3,
183  {"subi", "t,s,i", "t,s,i,E", 3,
185  {"and", "d,s,t", "d,s,t,E", 3,
187  {"andhi", "t,s,u", "t,s,u,E", 3,
189  {"andi", "t,s,u", "t,s,u,E", 3,
191  {"beq", "s,t,o", "s,t,o,E", 3,
193  {"bge", "s,t,o", "s,t,o,E", 3,
195  {"bgeu", "s,t,o", "s,t,o,E", 3,
197  {"bgt", "s,t,o", "s,t,o,E", 3,
200  {"bgtu", "s,t,o", "s,t,o,E", 3,
203  {"ble", "s,t,o", "s,t,o,E", 3,
206  {"bleu", "s,t,o", "s,t,o,E", 3,
209  {"blt", "s,t,o", "s,t,o,E", 3,
211  {"bltu", "s,t,o", "s,t,o,E", 3,
213  {"bne", "s,t,o", "s,t,o,E", 3,
215  {"br", "o", "o,E", 1,
217  {"break", "b", "b,E", 1,
219  {"bret", "", "E", 0,
221  {"flushd", "i(s)", "i(s)E", 2,
223  {"flushda", "i(s)", "i(s)E", 2,
225  {"flushi", "s", "s,E", 1,
227  {"flushp", "", "E", 0,
229  {"initd", "i(s)", "i(s)E", 2,
231  {"initda", "i(s)", "i(s)E", 2,
233  {"initi", "s", "s,E", 1,
235  {"call", "m", "m,E", 1,
237  {"callr", "s", "s,E", 1,
239  {"cmpeq", "d,s,t", "d,s,t,E", 3,
241  {"cmpeqi", "t,s,i", "t,s,i,E", 3,
243  {"cmpge", "d,s,t", "d,s,t,E", 3,
245  {"cmpgei", "t,s,i", "t,s,i,E", 3,
247  {"cmpgeu", "d,s,t", "d,s,t,E", 3,
249  {"cmpgeui", "t,s,u", "t,s,u,E", 3,
251  {"cmpgt", "d,s,t", "d,s,t,E", 3,
253  {"cmpgti", "t,s,i", "t,s,i,E", 3,
255  {"cmpgtu", "d,s,t", "d,s,t,E", 3,
257  {"cmpgtui", "t,s,u", "t,s,u,E", 3,
259  {"cmple", "d,s,t", "d,s,t,E", 3,
261  {"cmplei", "t,s,i", "t,s,i,E", 3,
263  {"cmpleu", "d,s,t", "d,s,t,E", 3,
265  {"cmpleui", "t,s,u", "t,s,u,E", 3,
267  {"cmplt", "d,s,t", "d,s,t,E", 3,
269  {"cmplti", "t,s,i", "t,s,i,E", 3,
271  {"cmpltu", "d,s,t", "d,s,t,E", 3,
273  {"cmpltui", "t,s,u", "t,s,u,E", 3,
275  {"cmpne", "d,s,t", "d,s,t,E", 3,
277  {"cmpnei", "t,s,i", "t,s,i,E", 3,
279  {"div", "d,s,t", "d,s,t,E", 3,
281  {"divu", "d,s,t", "d,s,t,E", 3,
283  {"jmp", "s", "s,E", 1,
285  {"jmpi", "m", "m,E", 1,
287  {"ldb", "t,i(s)", "t,i(s)E", 3,
289  {"ldbio", "t,i(s)", "t,i(s)E", 3,
291  {"ldbu", "t,i(s)", "t,i(s)E", 3,
293  {"ldbuio", "t,i(s)", "t,i(s)E", 3,
295  {"ldh", "t,i(s)", "t,i(s)E", 3,
297  {"ldhio", "t,i(s)", "t,i(s)E", 3,
299  {"ldhu", "t,i(s)", "t,i(s)E", 3,
301  {"ldhuio", "t,i(s)", "t,i(s)E", 3,
303  {"ldl", "t,i(s)", "t,i(s)E", 3,
305  {"ldw", "t,i(s)", "t,i(s)E", 3,
307  {"ldwio", "t,i(s)", "t,i(s)E", 3,
309  {"mov", "d,s", "d,s,E", 2,
311  no_overflow},
312  {"movhi", "t,u", "t,u,E", 2,
315  {"movui", "t,u", "t,u,E", 2,
318  {"movi", "t,i", "t,i,E", 2,
321  /* movia expands to two instructions so there is no mask or match */
322  {"movia", "t,o", "t,o,E", 2,
324  {"mul", "d,s,t", "d,s,t,E", 3,
326  {"muli", "t,s,i", "t,s,i,E", 3,
328  {"mulxss", "d,s,t", "d,s,t,E", 3,
330  {"mulxsu", "d,s,t", "d,s,t,E", 3,
332  {"mulxuu", "d,s,t", "d,s,t,E", 3,
334  {"nextpc", "d", "d,E", 1,
336  {"nop", "", "E", 0,
338  {"nor", "d,s,t", "d,s,t,E", 3,
340  {"or", "d,s,t", "d,s,t,E", 3,
342  {"orhi", "t,s,u", "t,s,u,E", 3,
344  {"ori", "t,s,u", "t,s,u,E", 3,
346  {"rdctl", "d,c", "d,c,E", 2,
348  {"rdprs", "t,s,i", "t,s,i,E", 3,
350  {"ret", "", "E", 0,
352  {"rol", "d,s,t", "d,s,t,E", 3,
354  {"roli", "d,s,j", "d,s,j,E", 3,
356  {"ror", "d,s,t", "d,s,t,E", 3,
358  {"sll", "d,s,t", "d,s,t,E", 3,
360  {"slli", "d,s,j", "d,s,j,E", 3,
362  {"sra", "d,s,t", "d,s,t,E", 3,
364  {"srai", "d,s,j", "d,s,j,E", 3,
366  {"srl", "d,s,t", "d,s,t,E", 3,
368  {"srli", "d,s,j", "d,s,j,E", 3,
370  {"stb", "t,i(s)", "t,i(s)E", 3,
372  {"stbio", "t,i(s)", "t,i(s)E", 3,
374  {"stc", "t,i(s)", "t,i(s)E", 3,
376  {"sth", "t,i(s)", "t,i(s)E", 3,
378  {"sthio", "t,i(s)", "t,i(s)E", 3,
380  {"stw", "t,i(s)", "t,i(s)E", 3,
382  {"stwio", "t,i(s)", "t,i(s)E", 3,
384  {"sub", "d,s,t", "d,s,t,E", 3,
386  {"sync", "", "E", 0,
388  {"trap", "b", "b,E", 1,
390  {"eret", "", "E", 0,
392  {"custom", "l,d,s,t", "l,d,s,t,E", 4,
394  {"wrctl", "c,s", "c,s,E", 2,
396  {"wrprs", "d,s", "d,s,E", 2,
398  {"xor", "d,s,t", "d,s,t,E", 3,
400  {"xorhi", "t,s,u", "t,s,u,E", 3,
402  {"xori", "t,s,u", "t,s,u,E", 3,
404 };
405 
406 #define NIOS2_NUM_OPCODES \
407  ((sizeof nios2_builtin_opcodes) / (sizeof (nios2_builtin_opcodes[0])))
409 
410 /* This is not const to allow for dynamic extensions to the
411  built-in instruction set. */
415 #undef NIOS2_NUM_OPCODES
const struct nios2_opcode nios2_builtin_opcodes[]
Definition: nios2-opc.c:175
const int bfd_nios2_num_builtin_opcodes
Definition: nios2-opc.c:408
struct nios2_reg * nios2_regs
Definition: nios2-opc.c:169
int bfd_nios2_num_opcodes
Definition: nios2-opc.c:414
#define NIOS2_NUM_OPCODES
Definition: nios2-opc.c:406
struct nios2_opcode * nios2_opcodes
Definition: nios2-opc.c:412
int nios2_num_regs
Definition: nios2-opc.c:170
#define NIOS2_NUM_REGS
Definition: nios2-opc.c:163
const int nios2_num_builtin_regs
Definition: nios2-opc.c:165
const struct nios2_reg nios2_builtin_regs[]
Definition: nios2-opc.c:29
#define OP_MASK_INITI
Definition: nios2.h:458
#define OP_MATCH_ANDI
Definition: nios2.h:355
#define OP_MATCH_CMPEQI
Definition: nios2.h:368
#define OP_MASK_SRAI
Definition: nios2.h:462
#define OP_MATCH_CMPLTU
Definition: nios2.h:415
#define OP_MATCH_CMPNEI
Definition: nios2.h:373
#define OP_MASK_RRT
Definition: nios2.h:207
#define OP_MASK_SRLI
Definition: nios2.h:463
#define OP_MATCH_MULXSU
Definition: nios2.h:422
#define OP_MASK_IOP
Definition: nios2.h:182
#define OP_MATCH_STW
Definition: nios2.h:396
#define OP_MATCH_CMPGE
Definition: nios2.h:412
#define OP_MATCH_SYNC
Definition: nios2.h:439
#define OP_MATCH_BLTU
Definition: nios2.h:360
#define OP_MATCH_STH
Definition: nios2.h:394
#define OP_MASK_BREAK
Definition: nios2.h:450
#define OP_MASK_TRAP
Definition: nios2.h:454
#define OP_MATCH_FLUSHDA
Definition: nios2.h:364
#define OP_MATCH_WRPRS
Definition: nios2.h:443
#define OP_MATCH_MUL
Definition: nios2.h:420
#define OP_MATCH_XORHI
Definition: nios2.h:399
#define NIOS2_INSN_ANDI
Definition: nios2.h:112
#define OP_MATCH_ADD
Definition: nios2.h:406
#define OP_MATCH_TRAP
Definition: nios2.h:440
#define OP_MATCH_RET
Definition: nios2.h:428
#define NIOS2_INSN_CBRANCH
Definition: nios2.h:108
#define OP_MATCH_SLL
Definition: nios2.h:432
#define OP_MATCH_LDH
Definition: nios2.h:379
#define OP_MATCH_MULI
Definition: nios2.h:386
#define OP_MATCH_LDW
Definition: nios2.h:384
#define OP_MATCH_LDBU
Definition: nios2.h:377
#define OP_MATCH_SLLI
Definition: nios2.h:433
#define OP_MATCH_DIV
Definition: nios2.h:417
@ signed_immed16_overflow
Definition: nios2.h:42
@ branch_target_overflow
Definition: nios2.h:40
@ custom_opcode_overflow
Definition: nios2.h:45
@ address_offset_overflow
Definition: nios2.h:41
@ unsigned_immed5_overflow
Definition: nios2.h:44
@ call_target_overflow
Definition: nios2.h:39
@ no_overflow
Definition: nios2.h:46
@ unsigned_immed16_overflow
Definition: nios2.h:43
#define NIOS2_INSN_CALL
Definition: nios2.h:109
#define OP_MATCH_LDHUIO
Definition: nios2.h:382
#define OP_MATCH_CUSTOM
Definition: nios2.h:398
#define OP_MATCH_BREAK
Definition: nios2.h:408
#define OP_MATCH_LDBIO
Definition: nios2.h:376
#define OP_MATCH_MULXSS
Definition: nios2.h:421
#define OP_MATCH_ROR
Definition: nios2.h:431
#define OP_MASK_JMP
Definition: nios2.h:452
#define OP_MATCH_CMPGEUI
Definition: nios2.h:370
#define OP_MATCH_CMPLT
Definition: nios2.h:414
#define OP_MATCH_BR
Definition: nios2.h:362
#define OP_MASK_SYNC
Definition: nios2.h:453
#define OP_MATCH_CMPEQ
Definition: nios2.h:411
#define OP_MATCH_ROLI
Definition: nios2.h:430
#define OP_MATCH_LDWIO
Definition: nios2.h:385
#define OP_MATCH_NEXTPC
Definition: nios2.h:424
#define OP_MATCH_BGEU
Definition: nios2.h:358
#define OP_MATCH_LDL
Definition: nios2.h:383
#define NIOS2_INSN_UBRANCH
Definition: nios2.h:107
#define OP_MATCH_BLT
Definition: nios2.h:359
#define OP_MATCH_JMPI
Definition: nios2.h:374
#define OP_MASK_SLLI
Definition: nios2.h:461
#define OP_MATCH_BNE
Definition: nios2.h:361
#define OP_MATCH_CMPNE
Definition: nios2.h:416
#define OP_MATCH_INITDA
Definition: nios2.h:366
#define OP_MATCH_RDCTL
Definition: nios2.h:427
#define OP_MATCH_WRCTL
Definition: nios2.h:442
#define OP_MATCH_FLUSHD
Definition: nios2.h:363
#define OP_MATCH_XOR
Definition: nios2.h:444
#define OP_MATCH_INITD
Definition: nios2.h:365
#define OP_MATCH_SRAI
Definition: nios2.h:435
#define OP_MATCH_SRL
Definition: nios2.h:436
#define OP_MATCH_CMPLTI
Definition: nios2.h:371
#define OP_MATCH_JMP
Definition: nios2.h:419
#define OP_MATCH_MULXUU
Definition: nios2.h:423
#define NIOS2_INSN_ORI
Definition: nios2.h:113
#define OP_MASK_ROLI
Definition: nios2.h:460
#define OP_MATCH_STWIO
Definition: nios2.h:397
#define OP_MASK_IRS
Definition: nios2.h:194
#define OP_MASK
Definition: nios2.h:467
#define OP_MATCH_CMPLTUI
Definition: nios2.h:372
#define OP_MATCH_STB
Definition: nios2.h:391
#define OP_MATCH_DIVU
Definition: nios2.h:418
#define OP_MATCH_STHIO
Definition: nios2.h:395
#define OP_MATCH_OR
Definition: nios2.h:426
#define NIOS2_INSN_MACRO_MOV
Definition: nios2.h:102
#define OP_MATCH_RDPRS
Definition: nios2.h:390
#define OP_MATCH_FLUSHP
Definition: nios2.h:446
#define OP_MATCH_LDB
Definition: nios2.h:375
#define OP_MATCH_FLUSHI
Definition: nios2.h:445
#define NIOS2_INSN_XORI
Definition: nios2.h:114
#define OP_MASK_ROP
Definition: nios2.h:198
#define OP_MASK_WRCTL
Definition: nios2.h:455
#define NIOS2_INSN_MACRO
Definition: nios2.h:101
#define NIOS2_INSN_MACRO_MOVI
Definition: nios2.h:103
#define OP_MATCH_LDBUIO
Definition: nios2.h:378
#define OP_MATCH_INITI
Definition: nios2.h:447
#define OP_MATCH_SRA
Definition: nios2.h:434
#define OP_MATCH_BEQ
Definition: nios2.h:356
#define OP_MATCH_CALL
Definition: nios2.h:367
#define OP_MATCH_SRLI
Definition: nios2.h:437
#define OP_MATCH_CALLR
Definition: nios2.h:410
#define OP_MASK_RDCTL
Definition: nios2.h:464
#define OP_MATCH_XORI
Definition: nios2.h:400
#define OP_MASK_FLUSHI
Definition: nios2.h:457
#define OP_MATCH_AND
Definition: nios2.h:407
#define OP_MATCH_STBIO
Definition: nios2.h:392
#define OP_MATCH_BRET
Definition: nios2.h:409
#define OP_MATCH_ANDHI
Definition: nios2.h:354
#define OP_MASK_ROPX
Definition: nios2.h:201
#define NIOS2_INSN_ADDI
Definition: nios2.h:111
#define OP_MATCH_SUB
Definition: nios2.h:438
#define OP_MATCH_LDHU
Definition: nios2.h:381
#define OP_MATCH_BGE
Definition: nios2.h:357
#define OP_MATCH_ORHI
Definition: nios2.h:388
#define NIOS2_INSN_MACRO_MOVIA
Definition: nios2.h:104
#define OP_MATCH_CMPGEI
Definition: nios2.h:369
#define OP_MATCH_ORI
Definition: nios2.h:389
#define OP_MASK_NEXTPC
Definition: nios2.h:456
#define OP_MATCH_ADDI
Definition: nios2.h:353
#define OP_MATCH_STC
Definition: nios2.h:393
#define OP_MASK_CALLR
Definition: nios2.h:451
#define OP_MATCH_NOR
Definition: nios2.h:425
#define OP_MATCH_CMPGEU
Definition: nios2.h:413
#define OP_MATCH_ERET
Definition: nios2.h:441
#define OP_MATCH_LDHIO
Definition: nios2.h:380
#define OP_MATCH_ROL
Definition: nios2.h:429