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