1 /*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /*
18 * Table of Dalvik opcode names.
19 */
20 #include "OpCodeNames.h"
21
22 #include <assert.h>
23
24 /*
25 * The following two lines work, but slashes and dashes both turn into
26 * underscores, and the strings are all upper case. The output is easier
27 * to read if we do the strings by hand (could probably write a
28 * post-processing function easily enough if maintenance becomes annoying).
29 */
30 //#define H(_op) #_op
31 //DEFINE_GOTO_TABLE(gOpNames)
32
33 /*
34 * Dalvik opcode names.
35 */
36 static const char* gOpNames[256] = {
37 /* 0x00 */
38 "nop",
39 "move",
40 "move/from16",
41 "move/16",
42 "move-wide",
43 "move-wide/from16",
44 "move-wide/16",
45 "move-object",
46 "move-object/from16",
47 "move-object/16",
48 "move-result",
49 "move-result-wide",
50 "move-result-object",
51 "move-exception",
52 "return-void",
53 "return",
54
55 /* 0x10 */
56 "return-wide",
57 "return-object",
58 "const/4",
59 "const/16",
60 "const",
61 "const/high16",
62 "const-wide/16",
63 "const-wide/32",
64 "const-wide",
65 "const-wide/high16",
66 "const-string",
67 "const-string/jumbo",
68 "const-class",
69 "monitor-enter",
70 "monitor-exit",
71 "check-cast",
72
73 /* 0x20 */
74 "instance-of",
75 "array-length",
76 "new-instance",
77 "new-array",
78 "filled-new-array",
79 "filled-new-array/range",
80 "fill-array-data",
81 "throw",
82 "goto",
83 "goto/16",
84 "goto/32",
85 "packed-switch",
86 "sparse-switch",
87 "cmpl-float",
88 "cmpg-float",
89 "cmpl-double",
90
91 /* 0x30 */
92 "cmpg-double",
93 "cmp-long",
94 "if-eq",
95 "if-ne",
96 "if-lt",
97 "if-ge",
98 "if-gt",
99 "if-le",
100 "if-eqz",
101 "if-nez",
102 "if-ltz",
103 "if-gez",
104 "if-gtz",
105 "if-lez",
106 "UNUSED",
107 "UNUSED",
108
109 /* 0x40 */
110 "UNUSED",
111 "UNUSED",
112 "UNUSED",
113 "UNUSED",
114 "aget",
115 "aget-wide",
116 "aget-object",
117 "aget-boolean",
118 "aget-byte",
119 "aget-char",
120 "aget-short",
121 "aput",
122 "aput-wide",
123 "aput-object",
124 "aput-boolean",
125 "aput-byte",
126
127 /* 0x50 */
128 "aput-char",
129 "aput-short",
130 "iget",
131 "iget-wide",
132 "iget-object",
133 "iget-boolean",
134 "iget-byte",
135 "iget-char",
136 "iget-short",
137 "iput",
138 "iput-wide",
139 "iput-object",
140 "iput-boolean",
141 "iput-byte",
142 "iput-char",
143 "iput-short",
144
145 /* 0x60 */
146 "sget",
147 "sget-wide",
148 "sget-object",
149 "sget-boolean",
150 "sget-byte",
151 "sget-char",
152 "sget-short",
153 "sput",
154 "sput-wide",
155 "sput-object",
156 "sput-boolean",
157 "sput-byte",
158 "sput-char",
159 "sput-short",
160 "invoke-virtual",
161 "invoke-super",
162
163 /* 0x70 */
164 "invoke-direct",
165 "invoke-static",
166 "invoke-interface",
167 "UNUSED",
168 "invoke-virtual/range",
169 "invoke-super/range",
170 "invoke-direct/range",
171 "invoke-static/range",
172 "invoke-interface/range",
173 "UNUSED",
174 "UNUSED",
175 "neg-int",
176 "not-int",
177 "neg-long",
178 "not-long",
179 "neg-float",
180
181 /* 0x80 */
182 "neg-double",
183 "int-to-long",
184 "int-to-float",
185 "int-to-double",
186 "long-to-int",
187 "long-to-float",
188 "long-to-double",
189 "float-to-int",
190 "float-to-long",
191 "float-to-double",
192 "double-to-int",
193 "double-to-long",
194 "double-to-float",
195 "int-to-byte",
196 "int-to-char",
197 "int-to-short",
198
199 /* 0x90 */
200 "add-int",
201 "sub-int",
202 "mul-int",
203 "div-int",
204 "rem-int",
205 "and-int",
206 "or-int",
207 "xor-int",
208 "shl-int",
209 "shr-int",
210 "ushr-int",
211 "add-long",
212 "sub-long",
213 "mul-long",
214 "div-long",
215 "rem-long",
216
217 /* 0xa0 */
218 "and-long",
219 "or-long",
220 "xor-long",
221 "shl-long",
222 "shr-long",
223 "ushr-long",
224 "add-float",
225 "sub-float",
226 "mul-float",
227 "div-float",
228 "rem-float",
229 "add-double",
230 "sub-double",
231 "mul-double",
232 "div-double",
233 "rem-double",
234
235 /* 0xb0 */
236 "add-int/2addr",
237 "sub-int/2addr",
238 "mul-int/2addr",
239 "div-int/2addr",
240 "rem-int/2addr",
241 "and-int/2addr",
242 "or-int/2addr",
243 "xor-int/2addr",
244 "shl-int/2addr",
245 "shr-int/2addr",
246 "ushr-int/2addr",
247 "add-long/2addr",
248 "sub-long/2addr",
249 "mul-long/2addr",
250 "div-long/2addr",
251 "rem-long/2addr",
252
253 /* 0xc0 */
254 "and-long/2addr",
255 "or-long/2addr",
256 "xor-long/2addr",
257 "shl-long/2addr",
258 "shr-long/2addr",
259 "ushr-long/2addr",
260 "add-float/2addr",
261 "sub-float/2addr",
262 "mul-float/2addr",
263 "div-float/2addr",
264 "rem-float/2addr",
265 "add-double/2addr",
266 "sub-double/2addr",
267 "mul-double/2addr",
268 "div-double/2addr",
269 "rem-double/2addr",
270
271 /* 0xd0 */
272 "add-int/lit16",
273 "rsub-int",
274 "mul-int/lit16",
275 "div-int/lit16",
276 "rem-int/lit16",
277 "and-int/lit16",
278 "or-int/lit16",
279 "xor-int/lit16",
280 "add-int/lit8",
281 "rsub-int/lit8",
282 "mul-int/lit8",
283 "div-int/lit8",
284 "rem-int/lit8",
285 "and-int/lit8",
286 "or-int/lit8",
287 "xor-int/lit8",
288
289 /* 0xe0 */
290 "shl-int/lit8",
291 "shr-int/lit8",
292 "ushr-int/lit8",
293 "+iget-volatile",
294 "+iput-volatile",
295 "+sget-volatile",
296 "+sput-volatile",
297 "+iget-object-volatile",
298 "+iget-wide-volatile",
299 "+iput-wide-volatile",
300 "+sget-wide-volatile",
301 "+sput-wide-volatile",
302 "^breakpoint", // does not appear in DEX files
303 "^throw-verification-error", // does not appear in DEX files
304 "+execute-inline",
305 "+execute-inline/range",
306
307 /* 0xf0 */
308 "+invoke-direct-empty",
309 "UNUSED",
310 "+iget-quick",
311 "+iget-wide-quick",
312 "+iget-object-quick",
313 "+iput-quick",
314 "+iput-wide-quick",
315 "+iput-object-quick",
316 "+invoke-virtual-quick",
317 "+invoke-virtual-quick/range",
318 "+invoke-super-quick",
319 "+invoke-super-quick/range",
320 "+iput-object-volatile",
321 "+sget-object-volatile",
322 "+sput-object-volatile",
323 "UNUSED",
324 };
325
326 /*
327 * Return the name of an opcode.
328 */
dexGetOpcodeName(OpCode op)329 const char* dexGetOpcodeName(OpCode op)
330 {
331 assert(op >= 0 && op < kNumDalvikInstructions);
332 return gOpNames[op];
333 }
334