OSDN Git Service

Merge "Return the value at the top of the mark stack straight away." into dalvik-dev
[android-x86/dalvik.git] / docs / dalvik-bytecode.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
3 <html>
4
5 <head>
6 <title>Bytecode for the Dalvik VM</title>
7 <link rel=stylesheet href="dalvik-bytecode.css">
8 </head>
9
10 <body>
11
12 <h1>Bytecode for the Dalvik VM</h1>
13 <p>Copyright &copy; 2007 The Android Open Source Project
14
15 <h2>General Design</h2>
16
17 <ul>
18 <li>The machine model and calling conventions are meant to approximately
19   imitate common real architectures and C-style calling conventions:
20   <ul>
21   <li>The VM is register-based, and frames are fixed in size upon creation.
22     Each frame consists of a particular number of registers (specified by
23     the method) as well as any adjunct data needed to execute the method,
24     such as (but not limited to) the program counter and a reference to the
25     <code>.dex</code> file that contains the method.
26   </li>
27   <li>When used for bit values (such as integers and floating point
28     numbers), registers are considered 32 bits wide. Adjacent register
29     pairs are used for 64-bit values. There is no alignment requirement
30     for register pairs.
31   </li>
32   <li>When used for object references, registers are considered wide enough
33     to hold exactly one such reference.
34   </li>
35   <li>In terms of bitwise representation, <code>(Object) null == (int)
36     0</code>.
37   </li>
38   <li>The <i>N</i> arguments to a method land in the last <i>N</i> registers
39     of the method's invocation frame, in order. Wide arguments consume
40     two registers. Instance methods are passed a <code>this</code> reference
41     as their first argument.
42   </li>
43   </ul>
44 <li>The storage unit in the instruction stream is a 16-bit unsigned quantity.
45   Some bits in some instructions are ignored / must-be-zero.
46 </li>
47 <li>Instructions aren't gratuitously limited to a particular type. For
48   example, instructions that move 32-bit register values without interpretation
49   don't have to specify whether they are moving ints or floats.
50 </li>
51 <li>There are separately enumerated and indexed constant pools for
52   references to strings, types, fields, and methods.
53 </li>
54 <li>Bitwise literal data is represented in-line in the instruction stream.</li>
55 <li>Because, in practice, it is uncommon for a method to need more than
56   16 registers, and because needing more than eight registers <i>is</i>
57   reasonably common, many instructions are limited to only addressing
58   the first 16
59   registers. When reasonably possible, instructions allow references to
60   up to the first 256 registers. In addition, some instructions have variants
61   that allow for much larger register counts, including a pair of catch-all
62   <code>move</code> instructions that can address registers in the range
63   <code>v0</code> &ndash; <code>v65535</code>.
64   In cases where an instruction variant isn't
65   available to address a desired register, it is expected that the register
66   contents get moved from the original register to a low register (before the
67   operation) and/or moved from a low result register to a high register
68   (after the operation).
69 </li>
70 <li>There are several "pseudo-instructions" that are used to hold
71   variable-length data referred to by regular instructions (for example,
72   <code>fill-array-data</code>). Such instructions must never be
73   encountered during the normal flow of execution. In addition, the
74   instructions must be located on even-numbered bytecode offsets (that is,
75   4-byte aligned). In order to meet this requirement, dex generation tools
76   must emit an extra <code>nop</code> instruction as a spacer if such an
77   instruction would otherwise be unaligned. Finally, though not required,
78   it is expected that most tools will choose to emit these instructions at
79   the ends of methods, since otherwise it would likely be the case that
80   additional instructions would be needed to branch around them.
81 </li>
82 <li>When installed on a running system, some instructions may be altered,
83   changing their format, as an install-time static linking optimization.
84   This is to allow for faster execution once linkage is known.
85   See the associated
86   <a href="instruction-formats.html">instruction formats document</a>
87   for the suggested variants. The word "suggested" is used advisedly;
88   it is not mandatory to implement these.
89 </li>
90 <li>Human-syntax and mnemonics:
91   <ul>
92   <li>Dest-then-source ordering for arguments.</li>
93   <li>Some opcodes have a disambiguating name suffix to indicate the type(s)
94     they operate on:
95     <ul>
96     <li>Type-general 32-bit opcodes are unmarked.</li>
97     <li>Type-general 64-bit opcodes are suffixed with <code>-wide</code>.</li>
98     <li>Type-specific opcodes are suffixed with their type (or a
99     straightforward abbreviation), one of: <code>-boolean</code>
100     <code>-byte</code> <code>-char</code> <code>-short</code>
101     <code>-int</code> <code>-long</code> <code>-float</code>
102     <code>-double</code> <code>-object</code> <code>-string</code>
103     <code>-class</code> <code>-void</code>.</li>
104     </ul>
105   </li>
106   <li>Some opcodes have a disambiguating suffix to distinguish
107     otherwise-identical operations that have different instruction layouts
108     or options. These suffixes are separated from the main names with a slash
109     ("<code>/</code>") and mainly exist at all to make there be a one-to-one
110     mapping with static constants in the code that generates and interprets
111     executables (that is, to reduce ambiguity for humans).
112   </li>
113   <li>In the descriptions here, the width of a value (indicating, e.g., the
114     range of a constant or the number of registers possibly addressed) is
115     emphasized by the use of a character per four bits of width.
116   </li>
117   <li>For example, in the instruction
118     "<code>move-wide/from16 vAA, vBBBB</code>":
119     <ul>
120     <li>"<code>move</code>" is the base opcode, indicating the base operation
121     (move a register's value).</li>
122     <li>"<code>wide</code>" is the name suffix, indicating that it operates
123     on wide (64 bit) data.</li>
124     <li>"<code>from16</code>" is the opcode suffix, indicating a variant
125     that has a 16-bit register reference as a source.</li>
126     <li>"<code>vAA</code>" is the destination register (implied by the
127     operation; again, the rule is that destination arguments always come
128     first), which must be in the range <code>v0</code> &ndash;
129     <code>v255</code>.</li>
130     <li>"<code>vBBBB</code>" is the source register, which must be in the
131     range <code>v0</code> &ndash; <code>v65535</code>.</li>
132     </ul>
133   </li>
134   </ul>
135 </li>
136 <li>See the <a href="instruction-formats.html">instruction formats
137   document</a> for more details about the various instruction formats
138   (listed under "Op &amp; Format") as well as details about the opcode
139   syntax.
140 </li>
141 <li>See the <a href="dex-format.html"><code>.dex</code> file format
142   document</a> for more details about where the bytecode fits into
143   the bigger picture.
144 </li>
145 </ul>
146
147 <h2>Summary of Instruction Set</h2>
148
149 <table class="instruc">
150 <thead>
151 <tr>
152   <th>Op &amp; Format</th>
153   <th>Mnemonic / Syntax</th>
154   <th>Arguments</th>
155   <th>Description</th>
156 </tr>
157 </thead>
158 <tbody>
159 <tr>
160   <td>00 10x</td>
161   <td>nop</td>
162   <td>&nbsp;</td>
163   <td>Waste cycles.
164     <p><b>Note:</b>
165     Data-bearing pseudo-instructions are tagged with this opcode, in which
166     case the high-order byte of the opcode unit indicates the nature of
167     the data. See "<code>packed-switch</code> Format",
168     "<code>sparse-switch</code> Format", and
169     "<code>fill-array-data</code> Format" below.</p>
170   </td>
171 </tr>
172 <tr>
173   <td>01 12x</td>
174   <td>move vA, vB</td>
175   <td><code>A:</code> destination register (4 bits)<br/>
176     <code>B:</code> source register (4 bits)</td>
177   <td>Move the contents of one non-object register to another.</td>
178 </tr>
179 <tr>
180   <td>02 22x</td>
181   <td>move/from16 vAA, vBBBB</td>
182   <td><code>A:</code> destination register (8 bits)<br/>
183     <code>B:</code> source register (16 bits)</td>
184   <td>Move the contents of one non-object register to another.</td>
185 </tr>
186 <tr>
187   <td>03 32x</td>
188   <td>move/16 vAAAA, vBBBB</td>
189   <td><code>A:</code> destination register (16 bits)<br/>
190     <code>B:</code> source register (16 bits)</td>
191   <td>Move the contents of one non-object register to another.</td>
192 </tr>
193 <tr>
194   <td>04 12x</td>
195   <td>move-wide vA, vB</td>
196   <td><code>A:</code> destination register pair (4 bits)<br/>
197     <code>B:</code> source register pair (4 bits)</td>
198   <td>Move the contents of one register-pair to another.
199     <p><b>Note:</b>
200     It is legal to move from <code>v<i>N</i></code> to either
201     <code>v<i>N-1</i></code> or <code>v<i>N+1</i></code>, so implementations
202     must arrange for both halves of a register pair to be read before
203     anything is written.</p>
204   </td>
205 </tr>
206 <tr>
207   <td>05 22x</td>
208   <td>move-wide/from16 vAA, vBBBB</td>
209   <td><code>A:</code> destination register pair (8 bits)<br/>
210     <code>B:</code> source register pair (16 bits)</td>
211   <td>Move the contents of one register-pair to another.
212     <p><b>Note:</b>
213     Implementation considerations are the same as <code>move-wide</code>,
214     above.</p>
215   </td>
216 </tr>
217 <tr>
218   <td>06 32x</td>
219   <td>move-wide/16 vAAAA, vBBBB</td>
220   <td><code>A:</code> destination register pair (16 bits)<br/>
221     <code>B:</code> source register pair (16 bits)</td>
222   <td>Move the contents of one register-pair to another.
223     <p><b>Note:</b>
224     Implementation considerations are the same as <code>move-wide</code>,
225     above.</p>
226   </td>
227 </tr>
228 <tr>
229   <td>07 12x</td>
230   <td>move-object vA, vB</td>
231   <td><code>A:</code> destination register (4 bits)<br/>
232     <code>B:</code> source register (4 bits)</td>
233   <td>Move the contents of one object-bearing register to another.</td>
234 </tr>
235 <tr>
236   <td>08 22x</td>
237   <td>move-object/from16 vAA, vBBBB</td>
238   <td><code>A:</code> destination register (8 bits)<br/>
239     <code>B:</code> source register (16 bits)</td>
240   <td>Move the contents of one object-bearing register to another.</td>
241 </tr>
242 <tr>
243   <td>09 32x</td>
244   <td>move-object/16 vAAAA, vBBBB</td>
245   <td><code>A:</code> destination register (16 bits)<br/>
246     <code>B:</code> source register (16 bits)</td>
247   <td>Move the contents of one object-bearing register to another.</td>
248 </tr>
249 <tr>
250   <td>0a 11x</td>
251   <td>move-result vAA</td>
252   <td><code>A:</code> destination register (8 bits)</td>
253   <td>Move the single-word non-object result of the most recent
254     <code>invoke-<i>kind</i></code> into the indicated register.
255     This must be done as the instruction immediately after an
256     <code>invoke-<i>kind</i></code> whose (single-word, non-object) result
257     is not to be ignored; anywhere else is invalid.</td>
258 </tr>
259 <tr>
260   <td>0b 11x</td>
261   <td>move-result-wide vAA</td>
262   <td><code>A:</code> destination register pair (8 bits)</td>
263   <td>Move the double-word result of the most recent
264     <code>invoke-<i>kind</i></code> into the indicated register pair.
265     This must be done as the instruction immediately after an
266     <code>invoke-<i>kind</i></code> whose (double-word) result
267     is not to be ignored; anywhere else is invalid.</td>
268 </tr>
269 <tr>
270   <td>0c 11x</td>
271   <td>move-result-object vAA</td>
272   <td><code>A:</code> destination register (8 bits)</td>
273   <td>Move the object result of the most recent <code>invoke-<i>kind</i></code>
274     into the indicated register. This must be done as the instruction
275     immediately after an <code>invoke-<i>kind</i></code> or
276     <code>filled-new-array</code>
277     whose (object) result is not to be ignored; anywhere else is invalid.</td>
278 </tr>
279 <tr>
280   <td>0d 11x</td>
281   <td>move-exception vAA</td>
282   <td><code>A:</code> destination register (8 bits)</td>
283   <td>Save a just-caught exception into the given register. This must
284     be the first instruction of any exception handler whose caught
285     exception is not to be ignored, and this instruction must <i>only</i>
286     ever occur as the first instruction of an exception handler; anywhere
287     else is invalid.</td>
288 </tr>
289 <tr>
290   <td>0e 10x</td>
291   <td>return-void</td>
292   <td>&nbsp;</td>
293   <td>Return from a <code>void</code> method.</td>
294 </tr>
295 <tr>
296   <td>0f 11x</td>
297   <td>return vAA</td>
298   <td><code>A:</code> return value register (8 bits)</td>
299   <td>Return from a single-width (32-bit) non-object value-returning
300     method.
301   </td>
302 </tr>
303 <tr>
304   <td>10 11x</td>
305   <td>return-wide vAA</td>
306   <td><code>A:</code> return value register-pair (8 bits)</td>
307   <td>Return from a double-width (64-bit) value-returning method.</td>
308 </tr>
309 <tr>
310   <td>11 11x</td>
311   <td>return-object vAA</td>
312   <td><code>A:</code> return value register (8 bits)</td>
313   <td>Return from an object-returning method.</td>
314 </tr>
315 <tr>
316   <td>12 11n</td>
317   <td>const/4 vA, #+B</td>
318   <td><code>A:</code> destination register (4 bits)<br/>
319     <code>B:</code> signed int (4 bits)</td>
320   <td>Move the given literal value (sign-extended to 32 bits) into
321     the specified register.</td>
322 </tr>
323 <tr>
324   <td>13 21s</td>
325   <td>const/16 vAA, #+BBBB</td>
326   <td><code>A:</code> destination register (8 bits)<br/>
327     <code>B:</code> signed int (16 bits)</td>
328   <td>Move the given literal value (sign-extended to 32 bits) into
329     the specified register.</td>
330 </tr>
331 <tr>
332   <td>14 31i</td>
333   <td>const vAA, #+BBBBBBBB</td>
334   <td><code>A:</code> destination register (8 bits)<br/>
335     <code>B:</code> arbitrary 32-bit constant</td>
336   <td>Move the given literal value into the specified register.</td>
337 </tr>
338 <tr>
339   <td>15 21h</td>
340   <td>const/high16 vAA, #+BBBB0000</td>
341   <td><code>A:</code> destination register (8 bits)<br/>
342     <code>B:</code> signed int (16 bits)</td>
343   <td>Move the given literal value (right-zero-extended to 32 bits) into
344     the specified register.</td>
345 </tr>
346 <tr>
347   <td>16 21s</td>
348   <td>const-wide/16 vAA, #+BBBB</td>
349   <td><code>A:</code> destination register (8 bits)<br/>
350     <code>B:</code> signed int (16 bits)</td>
351   <td>Move the given literal value (sign-extended to 64 bits) into
352     the specified register-pair.</td>
353 </tr>
354 <tr>
355   <td>17 31i</td>
356   <td>const-wide/32 vAA, #+BBBBBBBB</td>
357   <td><code>A:</code> destination register (8 bits)<br/>
358     <code>B:</code> signed int (32 bits)</td>
359   <td>Move the given literal value (sign-extended to 64 bits) into
360     the specified register-pair.</td>
361 </tr>
362 <tr>
363   <td>18 51l</td>
364   <td>const-wide vAA, #+BBBBBBBBBBBBBBBB</td>
365   <td><code>A:</code> destination register (8 bits)<br/>
366     <code>B:</code> arbitrary double-width (64-bit) constant</td>
367   <td>Move the given literal value into
368     the specified register-pair.</td>
369 </tr>
370 <tr>
371   <td>19 21h</td>
372   <td>const-wide/high16 vAA, #+BBBB000000000000</td>
373   <td><code>A:</code> destination register (8 bits)<br/>
374     <code>B:</code> signed int (16 bits)</td>
375   <td>Move the given literal value (right-zero-extended to 64 bits) into
376     the specified register-pair.</td>
377 </tr>
378 <tr>
379   <td>1a 21c</td>
380   <td>const-string vAA, string@BBBB</td>
381   <td><code>A:</code> destination register (8 bits)<br/>
382     <code>B:</code> string index</td>
383   <td>Move a reference to the string specified by the given index into the
384     specified register.</td>
385 </tr>
386 <tr>
387   <td>1b 31c</td>
388   <td>const-string/jumbo vAA, string@BBBBBBBB</td>
389   <td><code>A:</code> destination register (8 bits)<br/>
390     <code>B:</code> string index</td>
391   <td>Move a reference to the string specified by the given index into the
392     specified register.</td>
393 </tr>
394 <tr>
395   <td>1c 21c</td>
396   <td>const-class vAA, type@BBBB</td>
397   <td><code>A:</code> destination register (8 bits)<br/>
398     <code>B:</code> type index</td>
399   <td>Move a reference to the class specified by the given index into the
400     specified register. In the case where the indicated type is primitive,
401     this will store a reference to the primitive type's degenerate
402     class.</td>
403 </tr>
404 <tr>
405   <td>1d 11x</td>
406   <td>monitor-enter vAA</td>
407   <td><code>A:</code> reference-bearing register (8 bits)</td>
408   <td>Acquire the monitor for the indicated object.</td>
409 </tr>
410 <tr>
411   <td>1e 11x</td>
412   <td>monitor-exit vAA</td>
413   <td><code>A:</code> reference-bearing register (8 bits)</td>
414   <td>Release the monitor for the indicated object.
415     <p><b>Note:</b>
416     If this instruction needs to throw an exception, it must do
417     so as if the pc has already advanced past the instruction.
418     It may be useful to think of this as the instruction successfully
419     executing (in a sense), and the exception getting thrown <i>after</i>
420     the instruction but <i>before</i> the next one gets a chance to
421     run. This definition makes it possible for a method to use
422     a monitor cleanup catch-all (e.g., <code>finally</code>) block as
423     the monitor cleanup for that block itself, as a way to handle the
424     arbitrary exceptions that might get thrown due to the historical
425     implementation of <code>Thread.stop()</code>, while still managing
426     to have proper monitor hygiene.</p>
427   </td>
428 </tr>
429 <tr>
430   <td>1f 21c</td>
431   <td>check-cast vAA, type@BBBB</td>
432   <td><code>A:</code> reference-bearing register (8 bits)<br/>
433     <code>B:</code> type index (16 bits)</td>
434   <td>Throw a <code>ClassCastException</code> if the reference in the
435     given register cannot be cast to the indicated type.
436     <p><b>Note:</b> Since <code>A</code> must always be a reference
437     (and not a primitive value), this will necessarily fail at runtime
438     (that is, it will throw an exception) if <code>B</code> refers to a
439     primitive type.</p>
440   </td>
441 </tr>
442 <tr>
443   <td>20 22c</td>
444   <td>instance-of vA, vB, type@CCCC</td>
445   <td><code>A:</code> destination register (4 bits)<br/>
446     <code>B:</code> reference-bearing register (4 bits)<br/>
447     <code>C:</code> type index (16 bits)</td>
448   <td>Store in the given destination register <code>1</code>
449     if the indicated reference is an instance of the given type,
450     or <code>0</code> if not.
451     <p><b>Note:</b> Since <code>B</code> must always be a reference
452     (and not a primitive value), this will always result
453     in <code>0</code> being stored if <code>C</code> refers to a primitive
454     type.</td>
455 </tr>
456 <tr>
457   <td>21 12x</td>
458   <td>array-length vA, vB</td>
459   <td><code>A:</code> destination register (4 bits)<br/>
460     <code>B:</code> array reference-bearing register (4 bits)</td>
461   <td>Store in the given destination register the length of the indicated
462     array, in entries</td>
463 </tr>
464 <tr>
465   <td>22 21c</td>
466   <td>new-instance vAA, type@BBBB</td>
467   <td><code>A:</code> destination register (8 bits)<br/>
468     <code>B:</code> type index</td>
469   <td>Construct a new instance of the indicated type, storing a
470     reference to it in the destination. The type must refer to a
471     non-array class.</td>
472 </tr>
473 <tr>
474   <td>23 22c</td>
475   <td>new-array vA, vB, type@CCCC</td>
476   <td><code>A:</code> destination register (8 bits)<br/>
477     <code>B:</code> size register<br/>
478     <code>C:</code> type index</td>
479   <td>Construct a new array of the indicated type and size. The type
480     must be an array type.</td>
481 </tr>
482 <tr>
483   <td>24 35c</td>
484   <td>filled-new-array {vD, vE, vF, vG, vA}, type@CCCC</td>
485   <td><code>B:</code> array size and argument word count (4 bits)<br/>
486     <code>C:</code> type index (16 bits)<br/>
487     <code>D..G, A:</code> argument registers (4 bits each)</td>
488   <td>Construct an array of the given type and size, filling it with the
489     supplied contents. The type must be an array type. The array's
490     contents must be single-word (that is,
491     no arrays of <code>long</code> or <code>double</code>, but reference
492     types are acceptable). The constructed
493     instance is stored as a "result" in the same way that the method invocation
494     instructions store their results, so the constructed instance must
495     be moved to a register with an immediately subsequent
496     <code>move-result-object</code> instruction (if it is to be used).</td>
497 </tr>
498 <tr>
499   <td>25 3rc</td>
500   <td>filled-new-array/range {vCCCC .. vNNNN}, type@BBBB</td>
501   <td><code>A:</code> array size and argument word count (8 bits)<br/>
502     <code>B:</code> type index (16 bits)<br/>
503     <code>C:</code> first argument register (16 bits)<br/>
504     <code>N = A + C - 1</code></td>
505   <td>Construct an array of the given type and size, filling it with
506     the supplied contents. Clarifications and restrictions are the same
507     as <code>filled-new-array</code>, described above.</td>
508 </tr>
509 <tr>
510   <td>26 31t</td>
511   <td>fill-array-data vAA, +BBBBBBBB <i>(with supplemental data as specified
512     below in "<code>fill-array-data</code> Format")</i></td>
513   <td><code>A:</code> array reference (8 bits)<br/>
514     <code>B:</code> signed "branch" offset to table data pseudo-instruction
515     (32 bits)
516   </td>
517   <td>Fill the given array with the indicated data. The reference must be
518     to an array of primitives, and the data table must match it in type and
519     must contain no more elements than will fit in the array. That is,
520     the array may be larger than the table, and if so, only the initial
521     elements of the array are set, leaving the remainder alone.
522   </td>
523 </tr>
524 <tr>
525   <td>27 11x</td>
526   <td>throw vAA</td>
527   <td><code>A:</code> exception-bearing register (8 bits)<br/></td>
528   <td>Throw the indicated exception.</td>
529 </tr>
530 <tr>
531   <td>28 10t</td>
532   <td>goto +AA</td>
533   <td><code>A:</code> signed branch offset (8 bits)</td>
534   <td>Unconditionally jump to the indicated instruction.
535     <p><b>Note:</b>
536     The branch offset must not be <code>0</code>. (A spin
537     loop may be legally constructed either with <code>goto/32</code> or
538     by including a <code>nop</code> as a target before the branch.)</p>
539   </td>
540 </tr>
541 <tr>
542   <td>29 20t</td>
543   <td>goto/16 +AAAA</td>
544   <td><code>A:</code> signed branch offset (16 bits)<br/></td>
545   <td>Unconditionally jump to the indicated instruction.
546     <p><b>Note:</b>
547     The branch offset must not be <code>0</code>. (A spin
548     loop may be legally constructed either with <code>goto/32</code> or
549     by including a <code>nop</code> as a target before the branch.)</p>
550   </td>
551 </tr>
552 <tr>
553   <td>2a 30t</td>
554   <td>goto/32 +AAAAAAAA</td>
555   <td><code>A:</code> signed branch offset (32 bits)<br/></td>
556   <td>Unconditionally jump to the indicated instruction.</td>
557 </tr>
558 <tr>
559   <td>2b 31t</td>
560   <td>packed-switch vAA, +BBBBBBBB <i>(with supplemental data as
561     specified below in "<code>packed-switch</code> Format")</i></td>
562   <td><code>A:</code> register to test<br/>
563     <code>B:</code> signed "branch" offset to table data pseudo-instruction
564     (32 bits)
565   </td>
566   <td>Jump to a new instruction based on the value in the
567     given register, using a table of offsets corresponding to each value
568     in a particular integral range, or fall through to the next
569     instruction if there is no match.
570   </td>
571 </tr>
572 <tr>
573   <td>2c 31t</td>
574   <td>sparse-switch vAA, +BBBBBBBB <i>(with supplemental data as
575     specified below in "<code>sparse-switch</code> Format")</i></td>
576   <td><code>A:</code> register to test<br/>
577     <code>B:</code> signed "branch" offset to table data pseudo-instruction
578     (32 bits)
579   </td>
580   <td>Jump to a new instruction based on the value in the given
581     register, using an ordered table of value-offset pairs, or fall
582     through to the next instruction if there is no match.
583   </td>
584 </tr>
585 <tr>
586   <td>2d..31 23x</td>
587   <td>cmp<i>kind</i> vAA, vBB, vCC<br/>
588     2d: cmpl-float <i>(lt bias)</i><br/>
589     2e: cmpg-float <i>(gt bias)</i><br/>
590     2f: cmpl-double <i>(lt bias)</i><br/>
591     30: cmpg-double <i>(gt bias)</i><br/>
592     31: cmp-long
593   </td>
594   <td><code>A:</code> destination register (8 bits)<br/>
595     <code>B:</code> first source register or pair<br/>
596     <code>C:</code> second source register or pair</td>
597   <td>Perform the indicated floating point or <code>long</code> comparison,
598     storing <code>0</code> if the two arguments are equal, <code>1</code>
599     if the second argument is larger, or <code>-1</code> if the first
600     argument is larger. The "bias" listed for the floating point operations
601     indicates how <code>NaN</code> comparisons are treated: "Gt bias"
602     instructions return <code>1</code> for <code>NaN</code> comparisons,
603     and "lt bias" instructions return
604     <code>-1</code>.
605     <p>For example, to check to see if floating point
606     <code>a &lt; b</code>, then it is advisable to use
607     <code>cmpg-float</code>; a result of <code>-1</code> indicates that
608     the test was true, and the other values indicate it was false either
609     due to a valid comparison or because one or the other values was
610     <code>NaN</code>.</p>
611   </td>
612 </tr>
613 <tr>
614   <td>32..37 22t</td>
615   <td>if-<i>test</i> vA, vB, +CCCC<br/>
616     32: if-eq<br/>
617     33: if-ne<br/>
618     34: if-lt<br/>
619     35: if-ge<br/>
620     36: if-gt<br/>
621     37: if-le<br/>
622   </td>
623   <td><code>A:</code> first register to test (4 bits)<br/>
624     <code>B:</code> second register to test (4 bits)<br/>
625     <code>C:</code> signed branch offset (16 bits)</td>
626   <td>Branch to the given destination if the given two registers' values
627     compare as specified.
628     <p><b>Note:</b>
629     The branch offset must not be <code>0</code>. (A spin
630     loop may be legally constructed either by branching around a
631     backward <code>goto</code> or by including a <code>nop</code> as
632     a target before the branch.)</p>
633   </td>
634 </tr>
635 <tr>
636   <td>38..3d 21t</td>
637   <td>if-<i>test</i>z vAA, +BBBB<br/>
638     38: if-eqz<br/>
639     39: if-nez<br/>
640     3a: if-ltz<br/>
641     3b: if-gez<br/>
642     3c: if-gtz<br/>
643     3d: if-lez<br/>
644   </td>
645   <td><code>A:</code> register to test (8 bits)<br/>
646     <code>B:</code> signed branch offset (16 bits)</td>
647   <td>Branch to the given destination if the given register's value compares
648     with 0 as specified.
649     <p><b>Note:</b>
650     The branch offset must not be <code>0</code>. (A spin
651     loop may be legally constructed either by branching around a
652     backward <code>goto</code> or by including a <code>nop</code> as
653     a target before the branch.)</p>
654   </td>
655 </tr>
656 <tr>
657   <td>3e..43 10x</td>
658   <td><i>(unused)</i></td>
659   <td>&nbsp;</td>
660   <td><i>(unused)</i></td>
661 </tr>
662 <tr>
663   <td>44..51 23x</td>
664   <td><i>arrayop</i> vAA, vBB, vCC<br/>
665     44: aget<br/>
666     45: aget-wide<br/>
667     46: aget-object<br/>
668     47: aget-boolean<br/>
669     48: aget-byte<br/>
670     49: aget-char<br/>
671     4a: aget-short<br/>
672     4b: aput<br/>
673     4c: aput-wide<br/>
674     4d: aput-object<br/>
675     4e: aput-boolean<br/>
676     4f: aput-byte<br/>
677     50: aput-char<br/>
678     51: aput-short
679   </td>
680   <td><code>A:</code> value register or pair; may be source or dest
681       (8 bits)<br/>
682     <code>B:</code> array register (8 bits)<br/>
683     <code>C:</code> index register (8 bits)</td>
684   <td>Perform the identified array operation at the identified index of
685     the given array, loading or storing into the value register.</td>
686 </tr>
687 <tr>
688   <td>52..5f 22c</td>
689   <td>i<i>instanceop</i> vA, vB, field@CCCC<br/>
690     52: iget<br/>
691     53: iget-wide<br/>
692     54: iget-object<br/>
693     55: iget-boolean<br/>
694     56: iget-byte<br/>
695     57: iget-char<br/>
696     58: iget-short<br/>
697     59: iput<br/>
698     5a: iput-wide<br/>
699     5b: iput-object<br/>
700     5c: iput-boolean<br/>
701     5d: iput-byte<br/>
702     5e: iput-char<br/>
703     5f: iput-short
704   </td>
705   <td><code>A:</code> value register or pair; may be source or dest
706       (4 bits)<br/>
707     <code>B:</code> object register (4 bits)<br/>
708     <code>C:</code> instance field reference index (16 bits)</td>
709   <td>Perform the identified object instance field operation with
710     the identified field, loading or storing into the value register.
711     <p><b>Note:</b> These opcodes are reasonable candidates for static linking,
712     altering the field argument to be a more direct offset.</p>
713   </td>
714 </tr>
715 <tr>
716   <td>60..6d 21c</td>
717   <td>s<i>staticop</i> vAA, field@BBBB<br/>
718     60: sget<br/>
719     61: sget-wide<br/>
720     62: sget-object<br/>
721     63: sget-boolean<br/>
722     64: sget-byte<br/>
723     65: sget-char<br/>
724     66: sget-short<br/>
725     67: sput<br/>
726     68: sput-wide<br/>
727     69: sput-object<br/>
728     6a: sput-boolean<br/>
729     6b: sput-byte<br/>
730     6c: sput-char<br/>
731     6d: sput-short
732   </td>
733   <td><code>A:</code> value register or pair; may be source or dest
734       (8 bits)<br/>
735     <code>B:</code> static field reference index (16 bits)</td>
736   <td>Perform the identified object static field operation with the identified
737     static field, loading or storing into the value register.
738     <p><b>Note:</b> These opcodes are reasonable candidates for static linking,
739     altering the field argument to be a more direct offset.</p>
740   </td>
741 </tr>
742 <tr>
743   <td>6e..72 35c</td>
744   <td>invoke-<i>kind</i> {vD, vE, vF, vG, vA}, meth@CCCC<br/>
745     6e: invoke-virtual<br/>
746     6f: invoke-super<br/>
747     70: invoke-direct<br/>
748     71: invoke-static<br/>
749     72: invoke-interface
750   </td>
751   <td><code>B:</code> argument word count (4 bits)<br/>
752     <code>C:</code> method reference index (16 bits)<br/>
753     <code>D..G, A:</code> argument registers (4 bits each)</td>
754   <td>Call the indicated method. The result (if any) may be stored
755     with an appropriate <code>move-result*</code> variant as the immediately
756     subsequent instruction.
757     <p><code>invoke-virtual</code> is used to invoke a normal virtual
758     method (a method that is not <code>private</code>, <code>static</code>,
759     or <code>final</code>, and is also not a constructor).</p>
760     <p><code>invoke-super</code> is used to invoke the closest superclass's
761     virtual method (as opposed to the one with the same <code>method_id</code>
762     in the calling class). The same method restrictions hold as for
763     <code>invoke-virtual</code>.</p>
764     <p><code>invoke-direct</code> is used to invoke a non-<code>static</code>
765     direct method (that is, an instance method that is by its nature
766     non-overridable, namely either a <code>private</code> instance method
767     or a constructor).</p>
768     <p><code>invoke-static</code> is used to invoke a <code>static</code>
769     method (which is always considered a direct method).</p>
770     <p><code>invoke-interface</code> is used to invoke an
771     <code>interface</code> method, that is, on an object whose concrete
772     class isn't known, using a <code>method_id</code> that refers to
773     an <code>interface</code>.</p>
774     <p><b>Note:</b> These opcodes are reasonable candidates for static linking,
775     altering the method argument to be a more direct offset
776     (or pair thereof).</p>
777   </td>
778 </tr>
779 <tr>
780   <td>73 10x</td>
781   <td><i>(unused)</i></td>
782   <td>&nbsp;</td>
783   <td><i>(unused)</i></td>
784 </tr>
785 <tr>
786   <td>74..78 3rc</td>
787   <td>invoke-<i>kind</i>/range {vCCCC .. vNNNN}, meth@BBBB<br/>
788     74: invoke-virtual/range<br/>
789     75: invoke-super/range<br/>
790     76: invoke-direct/range<br/>
791     77: invoke-static/range<br/>
792     78: invoke-interface/range
793   </td>
794   <td><code>A:</code> argument word count (8 bits)<br/>
795     <code>B:</code> method reference index (16 bits)<br/>
796     <code>C:</code> first argument register (16 bits)<br/>
797     <code>N = A + C - 1</code></td>
798   <td>Call the indicated method. See first <code>invoke-<i>kind</i></code>
799     description above for details, caveats, and suggestions.
800   </td>
801 </tr>
802 <tr>
803   <td>79..7a 10x</td>
804   <td><i>(unused)</i></td>
805   <td>&nbsp;</td>
806   <td><i>(unused)</i></td>
807 </tr>
808 <tr>
809   <td>7b..8f 12x</td>
810   <td><i>unop</i> vA, vB<br/>
811     7b: neg-int<br/>
812     7c: not-int<br/>
813     7d: neg-long<br/>
814     7e: not-long<br/>
815     7f: neg-float<br/>
816     80: neg-double<br/>
817     81: int-to-long<br/>
818     82: int-to-float<br/>
819     83: int-to-double<br/>
820     84: long-to-int<br/>
821     85: long-to-float<br/>
822     86: long-to-double<br/>
823     87: float-to-int<br/>
824     88: float-to-long<br/>
825     89: float-to-double<br/>
826     8a: double-to-int<br/>
827     8b: double-to-long<br/>
828     8c: double-to-float<br/>
829     8d: int-to-byte<br/>
830     8e: int-to-char<br/>
831     8f: int-to-short
832   </td>
833   <td><code>A:</code> destination register or pair (4 bits)<br/>
834     <code>B:</code> source register or pair (4 bits)</td>
835   <td>Perform the identified unary operation on the source register,
836     storing the result in the destination register.</td>
837 </tr>
838
839 <tr>
840   <td>90..af 23x</td>
841   <td><i>binop</i> vAA, vBB, vCC<br/>
842     90: add-int<br/>
843     91: sub-int<br/>
844     92: mul-int<br/>
845     93: div-int<br/>
846     94: rem-int<br/>
847     95: and-int<br/>
848     96: or-int<br/>
849     97: xor-int<br/>
850     98: shl-int<br/>
851     99: shr-int<br/>
852     9a: ushr-int<br/>
853     9b: add-long<br/>
854     9c: sub-long<br/>
855     9d: mul-long<br/>
856     9e: div-long<br/>
857     9f: rem-long<br/>
858     a0: and-long<br/>
859     a1: or-long<br/>
860     a2: xor-long<br/>
861     a3: shl-long<br/>
862     a4: shr-long<br/>
863     a5: ushr-long<br/>
864     a6: add-float<br/>
865     a7: sub-float<br/>
866     a8: mul-float<br/>
867     a9: div-float<br/>
868     aa: rem-float<br/>
869     ab: add-double<br/>
870     ac: sub-double<br/>
871     ad: mul-double<br/>
872     ae: div-double<br/>
873     af: rem-double
874   </td>
875   <td><code>A:</code> destination register or pair (8 bits)<br/>
876     <code>B:</code> first source register or pair (8 bits)<br/>
877     <code>C:</code> second source register or pair (8 bits)</td>
878   <td>Perform the identified binary operation on the two source registers,
879     storing the result in the first source register.</td>
880 </tr>
881 <tr>
882   <td>b0..cf 12x</td>
883   <td><i>binop</i>/2addr vA, vB<br/>
884     b0: add-int/2addr<br/>
885     b1: sub-int/2addr<br/>
886     b2: mul-int/2addr<br/>
887     b3: div-int/2addr<br/>
888     b4: rem-int/2addr<br/>
889     b5: and-int/2addr<br/>
890     b6: or-int/2addr<br/>
891     b7: xor-int/2addr<br/>
892     b8: shl-int/2addr<br/>
893     b9: shr-int/2addr<br/>
894     ba: ushr-int/2addr<br/>
895     bb: add-long/2addr<br/>
896     bc: sub-long/2addr<br/>
897     bd: mul-long/2addr<br/>
898     be: div-long/2addr<br/>
899     bf: rem-long/2addr<br/>
900     c0: and-long/2addr<br/>
901     c1: or-long/2addr<br/>
902     c2: xor-long/2addr<br/>
903     c3: shl-long/2addr<br/>
904     c4: shr-long/2addr<br/>
905     c5: ushr-long/2addr<br/>
906     c6: add-float/2addr<br/>
907     c7: sub-float/2addr<br/>
908     c8: mul-float/2addr<br/>
909     c9: div-float/2addr<br/>
910     ca: rem-float/2addr<br/>
911     cb: add-double/2addr<br/>
912     cc: sub-double/2addr<br/>
913     cd: mul-double/2addr<br/>
914     ce: div-double/2addr<br/>
915     cf: rem-double/2addr
916   </td>
917   <td><code>A:</code> destination and first source register or pair
918       (4 bits)<br/>
919     <code>B:</code> second source register or pair (4 bits)</td>
920   <td>Perform the identified binary operation on the two source registers,
921     storing the result in the first source register.</td>
922 </tr>
923 <tr>
924   <td>d0..d7 22s</td>
925   <td><i>binop</i>/lit16 vA, vB, #+CCCC<br/>
926     d0: add-int/lit16<br/>
927     d1: rsub-int (reverse subtract)<br/>
928     d2: mul-int/lit16<br/>
929     d3: div-int/lit16<br/>
930     d4: rem-int/lit16<br/>
931     d5: and-int/lit16<br/>
932     d6: or-int/lit16<br/>
933     d7: xor-int/lit16
934   </td>
935   <td><code>A:</code> destination register (4 bits)<br/>
936     <code>B:</code> source register (4 bits)<br/>
937     <code>C:</code> signed int constant (16 bits)</td>
938   <td>Perform the indicated binary op on the indicated register (first
939     argument) and literal value (second argument), storing the result in
940     the destination register.
941     <p><b>Note:</b>
942     <code>rsub-int</code> does not have a suffix since this version is the
943     main opcode of its family. Also, see below for details on its semantics.
944     </p>
945   </td>
946 </tr>
947 <tr>
948   <td>d8..e2 22b</td>
949   <td><i>binop</i>/lit8 vAA, vBB, #+CC<br/>
950     d8: add-int/lit8<br/>
951     d9: rsub-int/lit8<br/>
952     da: mul-int/lit8<br/>
953     db: div-int/lit8<br/>
954     dc: rem-int/lit8<br/>
955     dd: and-int/lit8<br/>
956     de: or-int/lit8<br/>
957     df: xor-int/lit8<br/>
958     e0: shl-int/lit8<br/>
959     e1: shr-int/lit8<br/>
960     e2: ushr-int/lit8
961   </td>
962   <td><code>A:</code> destination register (8 bits)<br/>
963     <code>B:</code> source register (8 bits)<br/>
964     <code>C:</code> signed int constant (8 bits)</td>
965   <td>Perform the indicated binary op on the indicated register (first
966     argument) and literal value (second argument), storing the result
967     in the destination register.
968     <p><b>Note:</b> See below for details on the semantics of
969     <code>rsub-int</code>.</p>
970   </td>
971 </tr>
972 <tr>
973   <td>e3..fe 10x</td>
974   <td><i>(unused)</i></td>
975   <td>&nbsp;</td>
976   <td><i>(unused)</i></td>
977 </tr>
978 <tr>
979   <td>ff -</td>
980   <td><i>(expanded opcode)</i></td>
981   <td>&nbsp;</td>
982   <td>An <code>ff</code> in the primary opcode position indicates that there
983     is a secondary opcode in the high-order byte of the opcode code unit,
984     as opposed to an argument value. These expanded opcodes are detailed
985     immediately below.
986   </td>
987 </tr>
988 <tr>
989   <td>00ff 41c</td>
990   <td>const-class/jumbo vBBBB, type@AAAAAAAA</td>
991   <td><code>A:</code> type index (32 bits)<br/>
992     <code>B:</code> destination register (16 bits)</td>
993   <td>Move a reference to the class specified by the given index into the
994     specified register. See <code>const-class</code> description above
995     for details, caveats, and suggestions.
996   </td>
997 </tr>
998 <tr>
999   <td>01ff 41c</td>
1000   <td>check-cast/jumbo vBBBB, type@AAAAAAAA</td>
1001   <td><code>A:</code> type index (32 bits)<br/>
1002     <code>B:</code> reference-bearing register (16 bits)
1003   </td>
1004   <td>Throw a <code>ClassCastException</code> if the reference in the
1005     given register cannot be cast to the indicated type. See
1006     <code>check-cast</code> description above for details,
1007     caveats, and suggestions.
1008   </td>
1009 </tr>
1010 <tr>
1011   <td>02ff 52c</td>
1012   <td>instance-of/jumbo  vBBBB, vCCCC, type@AAAAAAAA</td>
1013   <td><code>A:</code> type index (32 bits)<br/>
1014     <code>B:</code> destination register (16 bits)<br/>
1015     <code>C:</code> reference-bearing register (16 bits)
1016   </td>
1017   <td>Store in the given destination register <code>1</code>
1018     if the indicated reference is an instance of the given type,
1019     or <code>0</code> if not. See
1020     <code>instance-of</code> description above for details,
1021     caveats, and suggestions.
1022   </td>
1023 </tr>
1024 <tr>
1025   <td>03ff 41c</td>
1026   <td>new-instance/jumbo vBBBB, type@AAAAAAAA</td>
1027   <td><code>A:</code> type index (32 bits)<br/>
1028     <code>B:</code> destination register (16 bits)
1029   </td>
1030   <td>Construct a new instance of the indicated type. See
1031     <code>new-instance</code> description above for details,
1032     caveats, and suggestions.
1033   </td>
1034 </tr>
1035 <tr>
1036   <td>04ff 52c</td>
1037   <td>new-array/jumbo vBBBB, vCCCC, type@AAAAAAAA</td>
1038   <td><code>A:</code> type index (32 bits)<br/>
1039     <code>B:</code> destination register (16 bits)<br/>
1040     <code>C:</code> size register (16 bits)
1041   </td>
1042   <td>Construct a new array of the indicated type and size. See
1043     <code>new-array</code> description above for details,
1044     caveats, and suggestions.
1045   </td>
1046 </tr>
1047 <tr>
1048   <td>05ff 5rc</td>
1049   <td>filled-new-array/jumbo {vCCCC .. vNNNN}, type@AAAAAAAA</td>
1050   <td><code>A:</code> type index (32 bits)<br/>
1051     <code>B:</code> array size and argument word count (16 bits)<br/>
1052     <code>C:</code> first argument register (16 bits)<br/>
1053     <code>N = B + C - 1</code>
1054   </td>
1055   <td>Construct an array of the given type and size, filling it with the
1056     supplied contents. See first
1057     <code>filled-new-array</code> description above for details,
1058     caveats, and suggestions.
1059   </td>
1060 </tr>
1061 <tr>
1062   <td>06ff..13ff 52c</td>
1063   <td>i<i>instanceop</i>/jumbo vBBBB, vCCCC, field@AAAAAAAA<br/>
1064     06ff: iget/jumbo<br/>
1065     07ff: iget-wide/jumbo<br/>
1066     08ff: iget-object/jumbo<br/>
1067     09ff: iget-boolean/jumbo<br/>
1068     0aff: iget-byte/jumbo<br/>
1069     0bff: iget-char/jumbo<br/>
1070     0cff: iget-short/jumbo<br/>
1071     0dff: iput/jumbo<br/>
1072     0eff: iput-wide/jumbo<br/>
1073     0fff: iput-object/jumbo<br/>
1074     10ff: iput-boolean/jumbo<br/>
1075     11ff: iput-byte/jumbo<br/>
1076     12ff: iput-char/jumbo<br/>
1077     13ff: iput-short/jumbo
1078   </td>
1079   <td><code>A:</code> instance field reference index (32 bits)<br/>
1080     <code>B:</code> value register or pair; may be source or dest
1081       (16 bits)<br/>
1082     <code>C:</code> object register (16 bits)
1083   </td>
1084   <td>Perform the identified object instance field operation. See
1085     <code>i<i>instanceop</i></code> description above for details,
1086     caveats, and suggestions.
1087   </td>
1088 </tr>
1089 <tr>
1090   <td>14ff..21ff 41c</td>
1091   <td>s<i>staticop</i>/jumbo vBBBB, field@AAAAAAAA<br/>
1092     14ff: sget/jumbo<br/>
1093     15ff: sget-wide/jumbo<br/>
1094     16ff: sget-object/jumbo<br/>
1095     17ff: sget-boolean/jumbo<br/>
1096     18ff: sget-byte/jumbo<br/>
1097     19ff: sget-char/jumbo<br/>
1098     1aff: sget-short/jumbo<br/>
1099     1bff: sput/jumbo<br/>
1100     1cff: sput-wide/jumbo<br/>
1101     1dff: sput-object/jumbo<br/>
1102     1eff: sput-boolean/jumbo<br/>
1103     1fff: sput-byte/jumbo<br/>
1104     20ff: sput-char/jumbo<br/>
1105     21ff: sput-short/jumbo
1106   </td>
1107   <td><code>A:</code> instance field reference index (32 bits)<br/>
1108     <code>B:</code> value register or pair; may be source or dest
1109       (16 bits)
1110   </td>
1111   <td>Perform the identified object static field operation. See
1112     <code>s<i>staticop</i></code> description above for details,
1113     caveats, and suggestions.
1114   </td>
1115 </tr>
1116 <tr>
1117   <td>22ff..26ff 5rc</td>
1118   <td>invoke-<i>kind</i>/jumbo {vCCCC .. vNNNN}, meth@AAAAAAAA<br/>
1119     22ff: invoke-virtual/jumbo<br/>
1120     23ff: invoke-super/jumbo<br/>
1121     24ff: invoke-direct/jumbo<br/>
1122     25ff: invoke-static/jumbo<br/>
1123     26ff: invoke-interface/jumbo
1124   </td>
1125   <td><code>A:</code> method reference index (32 bits)<br/>
1126     <code>B:</code> argument word count (16 bits)<br/>
1127     <code>C:</code> first argument register (16 bits)<br/>
1128     <code>N = B + C - 1</code>
1129   </td>
1130   <td>Call the indicated method. See first <code>invoke-<i>kind</i></code>
1131     description above for details, caveats, and suggestions.
1132   </td>
1133 </tr>
1134 </tbody>
1135 </table>
1136
1137 <h2><code>packed-switch</code> Format</h2>
1138
1139 <table class="supplement">
1140 <thead>
1141 <tr>
1142   <th>Name</th>
1143   <th>Format</th>
1144   <th>Description</th>
1145 </tr>
1146 </thead>
1147 <tbody>
1148 <tr>
1149   <td>ident</td>
1150   <td>ushort = 0x0100</td>
1151   <td>identifying pseudo-opcode</td>
1152 </tr>
1153 <tr>
1154   <td>size</td>
1155   <td>ushort</td>
1156   <td>number of entries in the table</td>
1157 </tr>
1158 <tr>
1159   <td>first_key</td>
1160   <td>int</td>
1161   <td>first (and lowest) switch case value</td>
1162 </tr>
1163 <tr>
1164   <td>targets</td>
1165   <td>int[]</td>
1166   <td>list of <code>size</code> relative branch targets. The targets are
1167     relative to the address of the switch opcode, not of this table.
1168   </td>
1169 </tr>
1170 </tbody>
1171 </table>
1172
1173 <p><b>Note:</b> The total number of code units for an instance of this
1174 table is <code>(size * 2) + 4</code>.</p>
1175
1176 <h2><code>sparse-switch</code> Format</h2>
1177
1178 <table class="supplement">
1179 <thead>
1180 <tr>
1181   <th>Name</th>
1182   <th>Format</th>
1183   <th>Description</th>
1184 </tr>
1185 </thead>
1186 <tbody>
1187 <tr>
1188   <td>ident</td>
1189   <td>ushort = 0x0200</td>
1190   <td>identifying pseudo-opcode</td>
1191 </tr>
1192 <tr>
1193   <td>size</td>
1194   <td>ushort</td>
1195   <td>number of entries in the table</td>
1196 </tr>
1197 <tr>
1198   <td>keys</td>
1199   <td>int[]</td>
1200   <td>list of <code>size</code> key values, sorted low-to-high</td>
1201 </tr>
1202 <tr>
1203   <td>targets</td>
1204   <td>int[]</td>
1205   <td>list of <code>size</code> relative branch targets, each corresponding
1206     to the key value at the same index. The targets are
1207     relative to the address of the switch opcode, not of this table.
1208   </td>
1209 </tr>
1210 </tbody>
1211 </table>
1212
1213 <p><b>Note:</b> The total number of code units for an instance of this
1214 table is <code>(size * 4) + 2</code>.</p>
1215
1216 <h2><code>fill-array-data</code> Format</h2>
1217
1218 <table class="supplement">
1219 <thead>
1220 <tr>
1221   <th>Name</th>
1222   <th>Format</th>
1223   <th>Description</th>
1224 </tr>
1225 </thead>
1226 <tbody>
1227 <tr>
1228   <td>ident</td>
1229   <td>ushort = 0x0300</td>
1230   <td>identifying pseudo-opcode</td>
1231 </tr>
1232 <tr>
1233   <td>element_width</td>
1234   <td>ushort</td>
1235   <td>number of bytes in each element</td>
1236 </tr>
1237 <tr>
1238   <td>size</td>
1239   <td>uint</td>
1240   <td>number of elements in the table</td>
1241 </tr>
1242 <tr>
1243   <td>data</td>
1244   <td>ubyte[]</td>
1245   <td>data values</td>
1246 </tr>
1247 </tbody>
1248 </table>
1249
1250 <p><b>Note:</b> The total number of code units for an instance of this
1251 table is <code>(size * element_width + 1) / 2 + 4</code>.</p>
1252
1253
1254 <h2>Mathematical Operation Details</h2>
1255
1256 <p><b>Note:</b> Floating point operations must follow IEEE 754 rules, using
1257 round-to-nearest and gradual underflow, except where stated otherwise.</p>
1258
1259 <table class="math">
1260 <thead>
1261 <tr>
1262   <th>Opcode</th>
1263   <th>C Semantics</th>
1264   <th>Notes</th>
1265 </tr>
1266 </thead>
1267 <tbody>
1268 <tr>
1269   <td>neg-int</td>
1270   <td>int32 a;<br/>
1271     int32 result = -a;
1272   </td>
1273   <td>Unary twos-complement.</td>
1274 </tr>
1275 <tr>
1276   <td>not-int</td>
1277   <td>int32 a;<br/>
1278     int32 result = ~a;
1279   </td>
1280   <td>Unary ones-complement.</td>
1281 </tr>
1282 <tr>
1283   <td>neg-long</td>
1284   <td>int64 a;<br/>
1285     int64 result = -a;
1286   </td>
1287   <td>Unary twos-complement.</td>
1288 </tr>
1289 <tr>
1290   <td>not-long</td>
1291   <td>int64 a;<br/>
1292     int64 result = ~a;
1293   </td>
1294   <td>Unary ones-complement.</td>
1295 </tr>
1296 <tr>
1297   <td>neg-float</td>
1298   <td>float a;<br/>
1299     float result = -a;
1300   </td>
1301   <td>Floating point negation.</td>
1302 </tr>
1303 <tr>
1304   <td>neg-double</td>
1305   <td>double a;<br/>
1306     double result = -a;
1307   </td>
1308   <td>Floating point negation.</td>
1309 </tr>
1310 <tr>
1311   <td>int-to-long</td>
1312   <td>int32 a;<br/>
1313     int64 result = (int64) a;
1314   </td>
1315   <td>Sign extension of <code>int32</code> into <code>int64</code>.</td>
1316 </tr>
1317 <tr>
1318   <td>int-to-float</td>
1319   <td>int32 a;<br/>
1320     float result = (float) a;
1321   </td>
1322   <td>Conversion of <code>int32</code> to <code>float</code>, using
1323     round-to-nearest. This loses precision for some values.
1324   </td>
1325 </tr>
1326 <tr>
1327   <td>int-to-double</td>
1328   <td>int32 a;<br/>
1329     double result = (double) a;
1330   </td>
1331   <td>Conversion of <code>int32</code> to <code>double</code>.</td>
1332 </tr>
1333 <tr>
1334   <td>long-to-int</td>
1335   <td>int64 a;<br/>
1336     int32 result = (int32) a;
1337   </td>
1338   <td>Truncation of <code>int64</code> into <code>int32</code>.</td>
1339 </tr>
1340 <tr>
1341   <td>long-to-float</td>
1342   <td>int64 a;<br/>
1343     float result = (float) a;
1344   </td>
1345   <td>Conversion of <code>int64</code> to <code>float</code>, using
1346     round-to-nearest. This loses precision for some values.
1347   </td>
1348 </tr>
1349 <tr>
1350   <td>long-to-double</td>
1351   <td>int64 a;<br/>
1352     double result = (double) a;
1353   </td>
1354   <td>Conversion of <code>int64</code> to <code>double</code>, using
1355     round-to-nearest. This loses precision for some values.
1356   </td>
1357 </tr>
1358 <tr>
1359   <td>float-to-int</td>
1360   <td>float a;<br/>
1361     int32 result = (int32) a;
1362   </td>
1363   <td>Conversion of <code>float</code> to <code>int32</code>, using
1364     round-toward-zero. <code>NaN</code> and <code>-0.0</code> (negative zero)
1365     convert to the integer <code>0</code>. Infinities and values with
1366     too large a magnitude to be represented get converted to either
1367     <code>0x7fffffff</code> or <code>-0x80000000</code> depending on sign.
1368   </td>
1369 </tr>
1370 <tr>
1371   <td>float-to-long</td>
1372   <td>float a;<br/>
1373     int64 result = (int64) a;
1374   </td>
1375   <td>Conversion of <code>float</code> to <code>int64</code>, using
1376     round-toward-zero. The same special case rules as for
1377     <code>float-to-int</code> apply here, except that out-of-range values
1378     get converted to either <code>0x7fffffffffffffff</code> or
1379     <code>-0x8000000000000000</code> depending on sign.
1380   </td>
1381 </tr>
1382 <tr>
1383   <td>float-to-double</td>
1384   <td>float a;<br/>
1385     double result = (double) a;
1386   </td>
1387   <td>Conversion of <code>float</code> to <code>double</code>, preserving
1388     the value exactly.
1389   </td>
1390 </tr>
1391 <tr>
1392   <td>double-to-int</td>
1393   <td>double a;<br/>
1394     int32 result = (int32) a;
1395   </td>
1396   <td>Conversion of <code>double</code> to <code>int32</code>, using
1397     round-toward-zero. The same special case rules as for
1398     <code>float-to-int</code> apply here.
1399   </td>
1400 </tr>
1401 <tr>
1402   <td>double-to-long</td>
1403   <td>double a;<br/>
1404     int64 result = (int64) a;
1405   </td>
1406   <td>Conversion of <code>double</code> to <code>int64</code>, using
1407     round-toward-zero. The same special case rules as for
1408     <code>float-to-long</code> apply here.
1409   </td>
1410 </tr>
1411 <tr>
1412   <td>double-to-float</td>
1413   <td>double a;<br/>
1414     float result = (float) a;
1415   </td>
1416   <td>Conversion of <code>double</code> to <code>float</code>, using
1417     round-to-nearest. This loses precision for some values.
1418   </td>
1419 </tr>
1420 <tr>
1421   <td>int-to-byte</td>
1422   <td>int32 a;<br/>
1423     int32 result = (a &lt;&lt; 24) &gt;&gt; 24;
1424   </td>
1425   <td>Truncation of <code>int32</code> to <code>int8</code>, sign
1426     extending the result.
1427   </td>
1428 </tr>
1429 <tr>
1430   <td>int-to-char</td>
1431   <td>int32 a;<br/>
1432     int32 result = a &amp; 0xffff;
1433   </td>
1434   <td>Truncation of <code>int32</code> to <code>uint16</code>, without
1435     sign extension.
1436   </td>
1437 </tr>
1438 <tr>
1439   <td>int-to-short</td>
1440   <td>int32 a;<br/>
1441     int32 result = (a &lt;&lt; 16) &gt;&gt; 16;
1442   </td>
1443   <td>Truncation of <code>int32</code> to <code>int16</code>, sign
1444     extending the result.
1445   </td>
1446 </tr>
1447 <tr>
1448   <td>add-int</td>
1449   <td>int32 a, b;<br/>
1450     int32 result = a + b;
1451   </td>
1452   <td>Twos-complement addition.</td>
1453 </tr>
1454 <tr>
1455   <td>sub-int</td>
1456   <td>int32 a, b;<br/>
1457     int32 result = a - b;
1458   </td>
1459   <td>Twos-complement subtraction.</td>
1460 </tr>
1461 <tr>
1462   <td>rsub-int</td>
1463   <td>int32 a, b;<br/>
1464     int32 result = b - a;
1465   </td>
1466   <td>Twos-complement reverse subtraction.</td>
1467 </tr>
1468 <tr>
1469   <td>mul-int</td>
1470   <td>int32 a, b;<br/>
1471     int32 result = a * b;
1472   </td>
1473   <td>Twos-complement multiplication.</td>
1474 </tr>
1475 <tr>
1476   <td>div-int</td>
1477   <td>int32 a, b;<br/>
1478     int32 result = a / b;
1479   </td>
1480   <td>Twos-complement division, rounded towards zero (that is, truncated to
1481     integer). This throws <code>ArithmeticException</code> if
1482     <code>b == 0</code>.
1483   </td>
1484 </tr>
1485 <tr>
1486   <td>rem-int</td>
1487   <td>int32 a, b;<br/>
1488     int32 result = a % b;
1489   </td>
1490   <td>Twos-complement remainder after division. The sign of the result
1491     is the same as that of <code>a</code>, and it is more precisely
1492     defined as <code>result == a - (a / b) * b</code>. This throws
1493     <code>ArithmeticException</code> if <code>b == 0</code>.
1494   </td>
1495 </tr>
1496 <tr>
1497   <td>and-int</td>
1498   <td>int32 a, b;<br/>
1499     int32 result = a &amp; b;
1500   </td>
1501   <td>Bitwise AND.</td>
1502 </tr>
1503 <tr>
1504   <td>or-int</td>
1505   <td>int32 a, b;<br/>
1506     int32 result = a | b;
1507   </td>
1508   <td>Bitwise OR.</td>
1509 </tr>
1510 <tr>
1511   <td>xor-int</td>
1512   <td>int32 a, b;<br/>
1513     int32 result = a ^ b;
1514   </td>
1515   <td>Bitwise XOR.</td>
1516 </tr>
1517 <tr>
1518   <td>shl-int</td>
1519   <td>int32 a, b;<br/>
1520     int32 result = a &lt;&lt; (b &amp; 0x1f);
1521   </td>
1522   <td>Bitwise shift left (with masked argument).</td>
1523 </tr>
1524 <tr>
1525   <td>shr-int</td>
1526   <td>int32 a, b;<br/>
1527     int32 result = a &gt;&gt; (b &amp; 0x1f);
1528   </td>
1529   <td>Bitwise signed shift right (with masked argument).</td>
1530 </tr>
1531 <tr>
1532   <td>ushr-int</td>
1533   <td>uint32 a, b;<br/>
1534     int32 result = a &gt;&gt; (b &amp; 0x1f);
1535   </td>
1536   <td>Bitwise unsigned shift right (with masked argument).</td>
1537 </tr>
1538 <tr>
1539   <td>add-long</td>
1540   <td>int64 a, b;<br/>
1541     int64 result = a + b;
1542   </td>
1543   <td>Twos-complement addition.</td>
1544 </tr>
1545 <tr>
1546   <td>sub-long</td>
1547   <td>int64 a, b;<br/>
1548     int64 result = a - b;
1549   </td>
1550   <td>Twos-complement subtraction.</td>
1551 </tr>
1552 <tr>
1553   <td>mul-long</td>
1554   <td>int64 a, b;<br/>
1555     int64 result = a * b;
1556   </td>
1557   <td>Twos-complement multiplication.</td>
1558 </tr>
1559 <tr>
1560   <td>div-long</td>
1561   <td>int64 a, b;<br/>
1562     int64 result = a / b;
1563   </td>
1564   <td>Twos-complement division, rounded towards zero (that is, truncated to
1565     integer). This throws <code>ArithmeticException</code> if
1566     <code>b == 0</code>.
1567   </td>
1568 </tr>
1569 <tr>
1570   <td>rem-long</td>
1571   <td>int64 a, b;<br/>
1572     int64 result = a % b;
1573   </td>
1574   <td>Twos-complement remainder after division. The sign of the result
1575     is the same as that of <code>a</code>, and it is more precisely
1576     defined as <code>result == a - (a / b) * b</code>. This throws
1577     <code>ArithmeticException</code> if <code>b == 0</code>.
1578   </td>
1579 </tr>
1580 <tr>
1581   <td>and-long</td>
1582   <td>int64 a, b;<br/>
1583     int64 result = a &amp; b;
1584   </td>
1585   <td>Bitwise AND.</td>
1586 </tr>
1587 <tr>
1588   <td>or-long</td>
1589   <td>int64 a, b;<br/>
1590     int64 result = a | b;
1591   </td>
1592   <td>Bitwise OR.</td>
1593 </tr>
1594 <tr>
1595   <td>xor-long</td>
1596   <td>int64 a, b;<br/>
1597     int64 result = a ^ b;
1598   </td>
1599   <td>Bitwise XOR.</td>
1600 </tr>
1601 <tr>
1602   <td>shl-long</td>
1603   <td>int64 a, b;<br/>
1604     int64 result = a &lt;&lt; (b &amp; 0x3f);
1605   </td>
1606   <td>Bitwise shift left (with masked argument).</td>
1607 </tr>
1608 <tr>
1609   <td>shr-long</td>
1610   <td>int64 a, b;<br/>
1611     int64 result = a &gt;&gt; (b &amp; 0x3f);
1612   </td>
1613   <td>Bitwise signed shift right (with masked argument).</td>
1614 </tr>
1615 <tr>
1616   <td>ushr-long</td>
1617   <td>uint64 a, b;<br/>
1618     int64 result = a &gt;&gt; (b &amp; 0x3f);
1619   </td>
1620   <td>Bitwise unsigned shift right (with masked argument).</td>
1621 </tr>
1622 <tr>
1623   <td>add-float</td>
1624   <td>float a, b;<br/>
1625     float result = a + b;
1626   </td>
1627   <td>Floating point addition.</td>
1628 </tr>
1629 <tr>
1630   <td>sub-float</td>
1631   <td>float a, b;<br/>
1632     float result = a - b;
1633   </td>
1634   <td>Floating point subtraction.</td>
1635 </tr>
1636 <tr>
1637   <td>mul-float</td>
1638   <td>float a, b;<br/>
1639     float result = a * b;
1640   </td>
1641   <td>Floating point multiplication.</td>
1642 </tr>
1643 <tr>
1644   <td>div-float</td>
1645   <td>float a, b;<br/>
1646     float result = a / b;
1647   </td>
1648   <td>Floating point division.</td>
1649 </tr>
1650 <tr>
1651   <td>rem-float</td>
1652   <td>float a, b;<br/>
1653     float result = a % b;
1654   </td>
1655   <td>Floating point remainder after division. This function is different
1656     than IEEE 754 remainder and is defined as
1657     <code>result == a - roundTowardZero(a / b) * b</code>.
1658   </td>
1659 </tr>
1660 <tr>
1661   <td>add-double</td>
1662   <td>double a, b;<br/>
1663     double result = a + b;
1664   </td>
1665   <td>Floating point addition.</td>
1666 </tr>
1667 <tr>
1668   <td>sub-double</td>
1669   <td>double a, b;<br/>
1670     double result = a - b;
1671   </td>
1672   <td>Floating point subtraction.</td>
1673 </tr>
1674 <tr>
1675   <td>mul-double</td>
1676   <td>double a, b;<br/>
1677     double result = a * b;
1678   </td>
1679   <td>Floating point multiplication.</td>
1680 </tr>
1681 <tr>
1682   <td>div-double</td>
1683   <td>double a, b;<br/>
1684     double result = a / b;
1685   </td>
1686   <td>Floating point division.</td>
1687 </tr>
1688 <tr>
1689   <td>rem-double</td>
1690   <td>double a, b;<br/>
1691     double result = a % b;
1692   </td>
1693   <td>Floating point remainder after division. This function is different
1694     than IEEE 754 remainder and is defined as
1695     <code>result == a - roundTowardZero(a / b) * b</code>.
1696   </td>
1697 </tr>
1698 </tbody>
1699 </table>
1700
1701 </body>
1702 </html>