Dalvik Instruction Set
Summary of Instruction Set
Op & Format |
Mnemonic / Syntax |
Arguments |
Description |
00 10x |
nop |
|
Waste cycles. |
01 12x |
move vA, vB |
|
Move the contents of one non-object register to another. |
02 22x |
move/from16 vAA, vBBBB |
|
Move the contents of one non-object register to another. |
03 32x |
move/16 vAAAA, vBBBB |
|
Move the contents of one non-object register to another. |
04 12x |
move-wide vA, vB |
|
Move the contents of one register-pair to another. Note: It is legal to move from |
05 22x |
move-wide/from16 vAA, vBBBB |
|
Move the contents of one register-pair to another. Note: Implementation considerations are the same as |
06 32x |
move-wide/16 vAAAA, vBBBB |
|
Move the contents of one register-pair to another. Note: Implementation considerations are the same as |
07 12x |
move-object vA, vB |
|
Move the contents of one object-bearing register to another. |
08 22x |
move-object/from16 vAA, vBBBB |
|
Move the contents of one object-bearing register to another. |
09 32x |
move-object/16 vAAAA, vBBBB |
|
Move the contents of one object-bearing register to another. |
0a 11x |
move-result vAA |
|
Move the single-word non-object
result of the most recent |
0b 11x |
move-result-wide vAA |
|
Move the double-word result of
the most recent |
0c 11x |
move-result-object vAA |
|
Move the object result of the
most recent |
0d 11x |
move-exception vAA |
|
Save a just-caught exception into the given register. This should be the first instruction of any exception handler whose caught exception is not to be ignored, and this instruction may only ever occur as the first instruction of an exception handler; anywhere else is invalid. |
0e 10x |
return-void |
|
Return from a |
0f 11x |
return vAA |
|
Return from a single-width (32-bit) non-object value-returning method. |
10 11x |
return-wide vAA |
|
Return from a double-width (64-bit) value-returning method. |
11 11x |
return-object vAA |
|
Return from an object-returning method. |
12 11n |
const/4 vA, #+B |
|
Move the given literal value (sign-extended to 32 bits) into the specified register. |
13 21s |
const/16 vAA, #+BBBB |
|
Move the given literal value (sign-extended to 32 bits) into the specified register. |
14 31i |
const vAA, #+BBBBBBBB |
|
Move the given literal value into the specified register. |
15 21h |
const/high16 vAA, #+BBBB0000 |
|
Move the given literal value (right-zero-extended to 32 bits) into the specified register. |
16 21s |
const-wide/16 vAA, #+BBBB |
|
Move the given literal value (sign-extended to 64 bits) into the specified register-pair. |
17 31i |
const-wide/32 vAA, #+BBBBBBBB |
|
Move the given literal value (sign-extended to 64 bits) into the specified register-pair. |
18 51l |
const-wide vAA, #+BBBBBBBBBBBBBBBB |
|
Move the given literal value into the specified register-pair. |
19 21h |
const-wide/high16 vAA, #+BBBB000000000000 |
|
Move the given literal value (right-zero-extended to 64 bits) into the specified register-pair. |
1a 21c |
const-string vAA, string@BBBB |
|
Move a reference to the string specified by the given index into the specified register. |
1b 31c |
const-string/jumbo vAA, string@BBBBBBBB |
|
Move a reference to the string specified by the given index into the specified register. |
1c 21c |
const-class vAA, type@BBBB |
|
Move a reference to the class specified by the given index into the specified register. In the case where the indicated type is primitive, this will store a reference to the primitive type's degenerate class. |
1d 11x |
monitor-enter vAA |
|
Acquire the monitor for the indicated object. |
1e 11x |
monitor-exit vAA |
|
Release the monitor for the indicated object. Note: If this instruction needs to throw an exception, it must do so
as if the pc has already advanced past the instruction. It may be useful to
think of this as the instruction successfully executing (in a sense), and the
exception getting thrown after the instruction butbefore the next one gets a chance to run.
This definition makes it possible for a method to use a monitor cleanup
catch-all (e.g., |
1f 21c |
check-cast vAA, type@BBBB |
|
Throw if the reference in the given register cannot be cast to the indicated type. The type must be a reference type (not a primitive type). |
20 22c |
instance-of vA, vB, type@CCCC |
|
Store in the given destination
register |
21 12x |
array-length vA, vB |
|
Store in the given destination register the length of the indicated array, in entries |
22 21c |
new-instance vAA, type@BBBB |
|
Construct a new instance of the indicated type, storing a reference to it in the destination. The type must refer to a non-array class. |
23 22c |
new-array vA, vB, type@CCCC |
|
Construct a new array of the indicated type and size. The type must be an array type. |
24 35c |
filled-new-array {vD, vE, vF, vG, vA}, type@CCCC |
|
Construct an array of the given
type and size, filling it with the supplied contents. The type must be an
array type. The array's contents must be single-word (that is, no arrays of |
25 3rc |
filled-new-array/range {vCCCC .. vNNNN}, type@BBBB |
|
Construct an array of the given
type and size, filling it with the supplied contents. Clarifications and
restrictions are the same as |
26 31t |
fill-array-data vAA, +BBBBBBBB (with supplemental data as specified below in " |
|
Fill the given array with the indicated data. The reference must be to an array of primitives, and the data table must match it in type and size. Note: The address of the table is guaranteed to be even (that is,
4-byte aligned). If the code size of the method is otherwise odd, then an
extra code unit is inserted between the main code and the table whose value
is the same as a |
27 11x |
throw vAA |
|
Throw the indicated exception. |
28 10t |
goto +AA |
|
Unconditionally jump to the indicated instruction. Note: The branch offset may not be |
29 20t |
goto/16 +AAAA |
|
Unconditionally jump to the indicated instruction. Note: The branch offset may not be |
2a 30t |
goto/32 +AAAAAAAA |
|
Unconditionally jump to the indicated instruction. |
2b 31t |
packed-switch vAA, +BBBBBBBB (with supplemental data as specified below in " |
|
Jump to a new instruction based on the value in the given register, using a table of offsets corresponding to each value in a particular integral range, or fall through to the next instruction if there is no match. Note: The address of the table is guaranteed to be even (that is,
4-byte aligned). If the code size of the method is otherwise odd, then an
extra code unit is inserted between the main code and the table whose value
is the same as a |
2c 31t |
sparse-switch vAA, +BBBBBBBB (with supplemental data as specified below in " |
|
Jump to a new instruction based on the value in the given register, using an ordered table of value-offset pairs, or fall through to the next instruction if there is no match. Note: Alignment and padding considerations are identical to |
2d..31 23x |
cmpkind vAA, vBB, vCC |
|
Perform the indicated floating
point or For example, to check to see if
floating point |
32..37 22t |
if-test vA, vB, +CCCC |
|
Branch to the given destination if the given two registers' values compare as specified. Note: The branch offset may not be |
38..3d 21t |
if-testz vAA, +BBBB |
|
Branch to the given destination if the given register's value compares with 0 as specified. Note: The branch offset may not be |
3e..43 10x |
(unused) |
|
(unused) |
44..51 23x |
arrayop vAA, vBB, vCC |
|
Perform the identified array operation at the identified index of the given array, loading or storing into the value register. |
52..5f 22c |
iinstanceop vA, vB,
field@CCCC |
|
Perform the identified object instance field operation with the identified field, loading or storing into the value register. Note: These opcodes are reasonable candidates for static linking, altering the field argument to be a more direct offset. |
60..6d 21c |
sstaticop vAA, field@BBBB |
|
Perform the identified object static field operation with the identified static field, loading or storing into the value register. Note: These opcodes are reasonable candidates for static linking, altering the field argument to be a more direct offset. |
6e..72 35c |
invoke-kind {vD, vE, vF,
vG, vA}, meth@CCCC |
|
Call the indicated method. The
result (if any) may be stored with an appropriate
Note: These opcodes are reasonable candidates for static linking, altering the method argument to be a more direct offset (or pair thereof). |
73 10x |
(unused) |
|
(unused) |
74..78 3rc |
invoke-kind/range
{vCCCC .. vNNNN}, meth@BBBB |
|
Call the indicated method. See
first |
79..7a 10x |
(unused) |
|
(unused) |
7b..8f 12x |
unop vA, vB |
|
Perform the identified unary operation on the source register, storing the result in the destination register. |
90..af 23x |
binop vAA, vBB, vCC |
|
Perform the identified binary operation on the two source registers, storing the result in the first source register. |
b0..cf 12x |
binop/2addr vA, vB |
|
Perform the identified binary operation on the two source registers, storing the result in the first source register. |
d0..d7 22s |
binop/lit16 vA, vB,
#+CCCC |
|
Perform the indicated binary op on the indicated register (first argument) and literal value (second argument), storing the result in the destination register. Note: |
d8..e2 22b |
binop/lit8 vAA, vBB,
#+CC |
|
Perform the indicated binary op on the indicated register (first argument) and literal value (second argument), storing the result in the destination register. Note: See below for details on the semantics of |
e3..ff 10x |
(unused) |
|
(unused) |
packed-switch
Format
Name |
Format |
Description |
ident |
ushort = 0x0100 |
identifying pseudo-opcode |
size |
ushort |
number of entries in the table |
first_key |
int |
first (and lowest) switch case value |
targets |
int[] |
list of |
Note: The total number of code units for an instance of this table is (size * 2) + 4
.
sparse-switch
Format
Name |
Format |
Description |
ident |
ushort = 0x0200 |
identifying pseudo-opcode |
size |
ushort |
number of entries in the table |
keys |
int[] |
list of |
targets |
int[] |
list of |
Note: The total number of code units for an instance of this table is (size * 4) + 2
.
fill-array-data
Format
Name |
Format |
Description |
ident |
ushort = 0x0300 |
identifying pseudo-opcode |
element_width |
ushort |
number of bytes in each element |
size |
uint |
number of elements in the table |
data |
ubyte[] |
data values |
Note: The total number of code units for an instance of this table is (size * element_width + 1) / 2 + 4
.
Mathematical Operation Details
Note: Floating point operations must follow IEEE 754 rules, using round-to-nearest and gradual underflow, except where stated otherwise.
Opcode |
C Semantics |
Notes |
neg-int |
int32 a; |
Unary twos-complement. |
not-int |
int32 a; |
Unary ones-complement. |
neg-long |
int64 a; |
Unary twos-complement. |
not-long |
int64 a; |
Unary ones-complement. |
neg-float |
float a; |
Floating point negation. |
neg-double |
double a; |
Floating point negation. |
int-to-long |
int32 a; |
Sign extension of |
int-to-float |
int32 a; |
Conversion of |
int-to-double |
int32 a; |
Conversion of |
long-to-int |
int64 a; |
Truncation of |
long-to-float |
int64 a; |
Conversion of |
long-to-double |
int64 a; |
Conversion of |
float-to-int |
float a; |
Conversion of |
float-to-long |
float a; |
Conversion of |
float-to-double |
float a; |
Conversion of |
double-to-int |
double a; |
Conversion of |
double-to-long |
double a; |
Conversion of |
double-to-float |
double a; |
Conversion of |
int-to-byte |
int32 a; |
Truncation of |
int-to-char |
int32 a; |
Truncation of |
int-to-short |
int32 a; |
Truncation of |
add-int |
int32 a, b; |
Twos-complement addition. |
sub-int |
int32 a, b; |
Twos-complement subtraction. |
rsub-int |
int32 a, b; |
Twos-complement reverse subtraction. |
mul-int |
int32 a, b; |
Twos-complement multiplication. |
div-int |
int32 a, b; |
Twos-complement division,
rounded towards zero (that is, truncated to integer). This throws |
rem-int |
int32 a, b; |
Twos-complement remainder after
division. The sign of the result is the same as that of |
and-int |
int32 a, b; |
Bitwise AND. |
or-int |
int32 a, b; |
Bitwise OR. |
xor-int |
int32 a, b; |
Bitwise XOR. |
shl-int |
int32 a, b; |
Bitwise shift left (with masked argument). |
shr-int |
int32 a, b; |
Bitwise signed shift right (with masked argument). |
ushr-int |
uint32 a, b; |
Bitwise unsigned shift right (with masked argument). |
add-long |
int64 a, b; |
Twos-complement addition. |
sub-long |
int64 a, b; |
Twos-complement subtraction. |
mul-long |
int64 a, b; |
Twos-complement multiplication. |
div-long |
int64 a, b; |
Twos-complement division,
rounded towards zero (that is, truncated to integer). This throws |
rem-long |
int64 a, b; |
Twos-complement remainder after
division. The sign of the result is the same as that of |
and-long |
int64 a, b; |
Bitwise AND. |
or-long |
int64 a, b; |
Bitwise OR. |
xor-long |
int64 a, b; |
Bitwise XOR. |
shl-long |
int64 a, b; |
Bitwise shift left (with masked argument). |
shr-long |
int64 a, b; |
Bitwise signed shift right (with masked argument). |
ushr-long |
uint64 a, b; |
Bitwise unsigned shift right (with masked argument). |
add-float |
float a, b; |
Floating point addition. |
sub-float |
float a, b; |
Floating point subtraction. |
mul-float |
float a, b; |
Floating point multiplication. |
div-float |
float a, b; |
Floating point division. |
rem-float |
float a, b; |
Floating point remainder after
division. This function is different than IEEE 754 remainder and is defined
as |
add-double |
double a, b; |
Floating point addition. |
sub-double |
double a, b; |
Floating point subtraction. |
mul-double |
double a, b; |
Floating point multiplication. |
div-double |
double a, b; |
Floating point division. |
rem-double |
double a, b; |
Floating point remainder after
division. This function is different than IEEE 754 remainder and is defined
as |