n=i>j?i-1:j+1;什么意思

旧闻、重复
内容质量差
当一家公司出现欠薪了,不要做任何犹豫,立马更新简历,寻找新的机会。
旧闻、重复
内容质量差
转载请标明出处: https://blog.csdn.net/xmxkf/article/details/
本文出自:【openXu的博客】
项目中有一些图表需求,一开始尝试使用一些开源的图表库,这些图表库功能很强大,图表种类应有尽有,是不错的选择。但是这些类库使用起来通常需要大量的设置,对于项目风格不能很好的贴合。于是自己尝试写了一个图表库,使用起来非常方便...
旧闻、重复
内容质量差
文章摘录于我在 gitchat 上的分享Spring Boot 2.0 的推出又激起了一阵学习 Spring Boot 热,就单从我个人的博客的访问量大幅增加就可以感受到...
旧闻、重复
内容质量差
Python3 初学实践案例(14)打造一个私人图床服务器
近来工作压力颇大,一直都在从事项目的开发工作,所以自学 python 的进度也拉下来一截,哎。由于进来很多项目用 react 编写,所以准备些一些相关的博客文章。但是博客的图片管理颇让人烦恼。之前尝试过把新浪微博当成图床,但是上传的稳定性一直是一个问题。使用 csdn 的博客图片上传功能吧,一直也比较不方便。因此,昨天突发奇想,决定写一...
旧闻、重复
内容质量差
不知从何时起, 知识付费变成了互联网新兴行业,开始变得越来越火热!在这个大背景下,越来越多的人选择以付费的形式来分享自己的技术和经验,越来越少的人还在免费的分享着自己的知...
旧闻、重复
内容质量差
西雅图IT圈:seattleit【今日作者】littlelann一个充满着人文情怀的web前端相声演员头一次听到有人说我“装逼”的时候,我忍不住在Espresso Viv...
旧闻、重复
内容质量差
点击上方“程序员大咖”,选择“置顶公众号”关键时刻,第一时间送达!忠诚单位不一定挽留有能力的员工,但对一个忠心耿耿的人,不会有领导愿意让他走,他会成为单位这个铁打营盘中最...
旧闻、重复
内容质量差
种种原因:我们很多人都有过写点东西的冲动,只是又因为种种原因没有发表。写着写着,挤不出字来了。总感觉自己的内心想法表达不出来。感觉写了没什么用,自己都明白了干嘛还要写。怕...
旧闻、重复
内容质量差
大数据可视化工具因其能将数字变成酷炫的图表而进入大众视野,但大家对该产品的了解还很有限,本文将从竞争格局、发展现状以及未来趋势三个维度具体探究大数据可视化工具市场的发展。...
旧闻、重复
内容质量差
IT行业技术变更周期越来越快,作为技术人最重要的是持续学习,现在的学习途径有很多,我们到底该如何做出选择?我觉得最重要有两方面:第一,需要保持良好的技术视野,持续关注行业...
旧闻、重复
内容质量差
本文来自《华为人》,转载请注明出处作者:于志国期间一位驰骋商界多年的老友问:“你现在在华为做什么工作呀?”我很骄傲地说:”系统架构师“,可是他却愣了很久。但当我老婆在旁边...
旧闻、重复
内容质量差
最近小编在后台收到这样一条消息:收到这条信息,相信你们也发现了,虽然这位小伙伴表面看似真的对转行人工智能做了功夫(下载100G学习干货),但是没有下功夫去好好学习,没有实...
旧闻、重复
内容质量差
作为一名从事IT行业的女性程序员,首次向网友们吐露出自己的心声,虽然高考失利,但是也努力进了百度,自己也觉得不错。之后换到了阿里的支付宝部门工作,而且导师也还不错,也挺优秀。但自己担心最多的就是这些年来一直单身,想嫁一个程序员成了泡影。下面评论就炸开了锅,全是类似于“别说了,发邮箱吧,我投简历还不行吗”,“明人不说暗话,我喜欢上你了”这样的话。然后搞的楼主小姐姐一脸懵逼:为什么都在说简历?什么梗?...
旧闻、重复
内容质量差
2018年,互联网行业风起云涌,IT工程师如果仅凭传统开发思维,无法突破固有知识体系,终将会被社会所淘汰。既需要掌控整体又需要洞悉局部瓶颈并依据具体的业务场景给出解决方案...
旧闻、重复
内容质量差
关注「实验楼」,每天分享一个项目教程
近日,著名数据科学网站 KDnuggets 发布了 2018 年数据科学和机器学习工具调查结果。超过 2000 人对自己「过去 ...
旧闻、重复
内容质量差
作者:hsm_computer来源:http://www.cnblogs.com/JavaArchitect程序员忙,似乎是个公论,有些程序员甚至会认为,不忙的程序员无法...
旧闻、重复
内容质量差
本文基于几篇经典的论文,对 Attention 模型的不同结构进行分析、拆解。先简单谈一谈 attention 模型的引入。以基于 seq2seq 模型的机器翻译为例,如...
旧闻、重复
内容质量差
【数据猿导读】本篇案例涉及企业是一家国外顶级零售商,合作方在美国具有良好的数据支持,并已研发出成熟的选址模型,在美国表现效果非常良好,但当合作方将其模型拿到中国市场时,却...
旧闻、重复
内容质量差
最近,前程无忧论坛发起了投票调查,结果显示,88%的受访者有跳槽的打算,12%的受访者目前不想跳槽。
想跳槽的朋友有没有想过这样一个问题,提了离职却被公司加薪挽留,这时候你怎么办?到底是走还是不走?
我们的无忧专家是这么建议的:
遇到此类问题,你需要考虑两个问题:
1、促使你跳槽的问题已经解决了吗?当初你跳槽的原因是什么,如果只是因为薪水问题,现在老板承诺加...
旧闻、重复
内容质量差
前言借书正式出版之际,完整回顾下从写博客到写书整个历程,也算是对自己近三年在技术上的一个总结,整个历程可通过三个万万没想到来概括,请耐心阅读。写博、写书完整历程回顾从20...
旧闻、重复
内容质量差
要说史上最著名的猫,大概就是薛定谔的那只了。它被关在装有少量镭和氰化物的密闭容器里,当镭发生衰变时,就会触发机关打碎装有氰化物的瓶子,猫就会死亡;如果镭不发生衰变,猫就会...
刚刚阅读在这里,点击刷新
刚刚阅读在这里,点击刷新
周君 · 资深后端攻城狮
邢森 · 电信架构师
即便作为兴趣爱好,无人价值技术要如何入门呢?
《程序员》杂志
我们请来 AI 技术一线的专家,请他们从实践的角度来解析 AI 领域各技术岗位的合格工程师都是怎样炼成的。
这个栏目将帮助大家筛选出人工智能和机器学习领域,每年各大顶级会议和研讨班上有意思的论文,解读出论文的核心思想,为精读提供阅读指导。
本期我们梳理了2017年区块链发展现状,从关键技术原理与实际应用出发,带你深入浅出探索区块链技术的方方面面。
16个主题,200余篇文章,180万字——不容错过的前沿技术、工具尽在其中,亲历者领域案例剖析
成都-光谷创业咖啡(长发街55号3-4)smali举例:
.class public Lcom/dataviz/dxtg/common/android/DocsToGoA
.super Landroid/app/A
# static fields
.field private static a:Landroid/app/A
## 静态字段 Application
.field private static b:Lcom/dataviz/dxtg/common/android/
## 静态字段 bv
# direct methods
.method static constructor &clinit&()V
## 静态方法,静态成员的初始化。
##一个局部变量
const/4 v0, 0x0
##v0寄存器低4字节存放0,可表示0,null,false
sput-object v0, Lcom/dataviz/dxtg/common/android/DocsToGoA-&a:Landroid/app/A
sput-object v0, Lcom/dataviz/dxtg/common/android/DocsToGoA-&b:Lcom/dataviz/dxtg/common/android/
return-void ## 无返回值 Return without a return value , 字节码 0E00 - return-void
.end method
.method public constructor &init&()V
## 构造函数
invoke-direct {p0}, Landroid/app/A-&&init&()V
## super.Application();
sput-object p0, Lcom/dataviz/dxtg/common/android/DocsToGoA-&a:Landroid/app/A ## a =
return-void
.end method
.method public static a()Landroid/content/C
## 静态方法
sget-object v0, Lcom/dataviz/dxtg/common/android/DocsToGoA-&a:Landroid/app/A
invoke-virtual {v0}, Landroid/app/A-&getApplicationContext()Landroid/content/C
move-result-object v0
return-object v0
.end method
.method public static a(Ljava/lang/S)Ljava/lang/S## 静态方法
const-string/jumbo v0, "x.xxx"
invoke-virtual {v0}, Ljava/lang/S-&length()I
move-result v0
invoke-virtual {p0}, Ljava/lang/S-&length()I
move-result v1
if-le v1, v0, :cond_0
const/4 v1, 0x0
invoke-virtual {p0, v1, v0}, Ljava/lang/S-&substring(II)Ljava/lang/S
move-result-object p0
return-object p0
.end method
.method public static a(Ljava/lang/R)V
## 静态方法
invoke-static {}, Lcom/dataviz/dxtg/common/android/DocsToGoA-&a()Landroid/content/C
move-result-object v0
invoke-virtual {v0}, Landroid/content/C-&getMainLooper()Landroid/os/L
move-result-object v0
new-instance v1, Landroid/os/H
invoke-direct {v1, v0}, Landroid/os/H-&&init&(Landroid/os/L)V
invoke-virtual {v1, p0}, Landroid/os/H-&post(Ljava/lang/R)Z
return-void
.end method
.method public static b()Landroid/content/res/R
## 静态方法
sget-object v0, Lcom/dataviz/dxtg/common/android/DocsToGoA-&a:Landroid/app/A
invoke-virtual {v0}, Landroid/app/A-&getResources()Landroid/content/res/R
move-result-object v0
return-object v0
.end method
.method public static c()Lcom/dataviz/dxtg/common/android/
## 静态方法
sget-object v0, Lcom/dataviz/dxtg/common/android/DocsToGoA-&b:Lcom/dataviz/dxtg/common/android/
if-nez v0, :cond_0
const-wide/16 v0, 0x1f4
:try_start_0
invoke-static {v0, v1}, Ljava/lang/T-&sleep(J)V
:try_end_0
.catch Ljava/lang/T {:try_start_0 .. :try_end_0} :catch_0
sget-object v0, Lcom/dataviz/dxtg/common/android/DocsToGoA-&b:Lcom/dataviz/dxtg/common/android/
return-object v0
move-exception v0
goto :goto_0
.end method
# virtual methods
.method public onCreate()V
## onCreate方法
:try_start_0
invoke-static {}, Lcom/dataviz/dxtg/common/android/e/g;-&a()Lcom/dataviz/dxtg/common/android/e/g;
move-result-object v0
invoke-virtual {p0}, Lcom/dataviz/dxtg/common/android/DocsToGoA-&getPackageName()Ljava/lang/S
move-result-object v1
invoke-virtual {v0, v1}, Lcom/dataviz/dxtg/common/android/e/g;-&a(Ljava/lang/S)V
:try_end_0
.catch Ljava/lang/T {:try_start_0 .. :try_end_0} :catch_0
new-instance v0, Landroid/os/H
invoke-direct {v0}, Landroid/os/H-&&init&()V
new-instance v1, Lcom/dataviz/dxtg/common/android/
invoke-direct {v1, p0}, Lcom/dataviz/dxtg/common/android/-&&init&(Lcom/dataviz/dxtg/common/android/DocsToGoA)V
invoke-virtual {v0, v1}, Landroid/os/H-&postAtFrontOfQueue(Ljava/lang/R)Z
new-instance v0, Lcom/dataviz/dxtg/common/android/
invoke-direct {v0, p0}, Lcom/dataviz/dxtg/common/android/-&&init&(Landroid/content/C)V
invoke-virtual {v0}, Lcom/dataviz/dxtg/common/android/-&a()V
sput-object v0, Lcom/dataviz/dxtg/common/android/DocsToGoA-&b:Lcom/dataviz/dxtg/common/android/
return-void
move-exception v0
invoke-virtual {v0}, Ljava/lang/T-&printStackTrace()V
goto :goto_0
.end method
sput-object vx,field_id
Puts object reference in vx into a static field.
- sput-object v0, Test3.os1:Ljava/lang/O // field@000c Puts the object reference value in v0 into the field@000c static field (entry #CH in the field id table).
将vx引用对象赋值给静态变量字段field_id.
const/4 vx,lit4
Puts the 4 bit constant into vx
1221 - const/4 v1, #int2 Moves literal 2 into v1. The destination register is in the lower 4 bit in the second byte, the literal 2 is in the higher 4 bit.
lit4逐字节放到vx低4位。
Android java下smali指令
关于几个调用方法指令:&invoke-virtual、invoke-direct、invoke-super介绍。
涉及到Java强大的动态扩展能力,这一特性使得可以在类运行期间才能确定某些目标方法的实际引用,称为动态连接;也有一部分方法的符号引用在类加载阶段或第一次使用时转化为直接引用,这种转化称为静态解析。
在Java语言中,符合&编译器可知,运行期不可变&这个要求的方法主要有静态方法和私有方法两大类,前者与类型直接关联,后者在外部不可被访问,这两种方法都不可能通过继承或别的方式重写出其他的版本,因此它们都适合在类加载阶段进行解析。
invoke-static 是类静态方法的调用,编译时,静态确定的;
invoke-virtual 虚方法调用,调用的方法运行时确认实际调用,和实例引用的实际对象有关,动态确认的,一般是带有修饰符protected或public的方法;
invoke-direct 没有被覆盖方法的调用,即不用动态根据实例所引用的调用,编译时,静态确认的,一般是private或&init&方法;
invoke-super 直接调用父类的虚方法,编译时,静态确认的。
invokeinterface 调用接口方法,调用的方法运行时确认实际调用,即会在运行时才确定一个实现此接口的对象。
invoke-static&{v3,v0}, Landroid/util/-&v(Ljava/lang/SLjava/lang/S)
invoke-virtual {v1}, Landroid/app/A-&getApplicationContext()Landroid/content/C
invoke-direct {v0, v4}, Lcom/android/server/LightsS-&&init&(Landroid/content/C)V
invoke-super {p0, p1}, Landroid/preference/PreferenceA-&onCreate(Landroid/os/B)V&
invoke-super {p0, p1, p2}, Landroid/view/V-&onKeyUp(ILandroid/view/KeyE)Z
invoke-super&{p0, p1}, Landroid/app/A-&onCreate(Landroid/os/B)V&
new-instance v2, Ljava/lang/StringB &# StringBuilder实例
invoke-direct {v2},&Ljava/lang/StringB-&&init&()V &# 调用 StringBuilder 构造函数
invoke-static {}, Landroid/os/E-&getExternalStorageDirectory()Ljava/io/F #静态方法
move-result-object v3&
invoke-virtual {v2, v3}, Ljava/lang/StringB-&append(Ljava/lang/O)Ljava/lang/StringB #public方法
&invoke-direct/range {v8 .. v13}, Lcom/android/server/net/NetworkPolicyManagerS-&&init&
invoke-virtual { parameters }, methodtocall
Invokes a virtual method with parameters.
- invoke-virtual { v4, v0, v1, v2, v3}, Test2.method5:(IIII)V // method@0006Invokes the 6th method in the method table with the following arguments: v4 is the "this" instance, v0, v1, v2, and v3 are the method parameters. The method has 5 arguments (4 MSB bits of the second byte)5.
invoke-super {parameter},methodtocall
Invokes the virtual method of the immediate parent class.
6F10 A601 0100 invoke-super {v1},java.io.FilterOutputStream.close:()V // method@01a6Invokes method@01a6 with one parameter, v1.
invoke-direct { parameters }, methodtocall
Invokes a method with parameters without the virtual method resolution.
00 - invoke-direct {v1}, java.lang.Object.&init&:()V // method@0008Invokes the 8th method in the method table with just one parameter, v1 is the "this" instance5.
invoke-static {parameters}, methodtocall
Invokes a static method with parameters.
00 - invoke-static {v4}, java.lang.Integer.parseInt:( Ljava/lang/S)I // method@0034Invokes method@34 static method. The method is called with one parameter, v45.
invoke-interface {parameters},methodtocall
Invokes an interface method.
54 invoke-interface {v1, v3, v4, v5}, mwfw.IReceivingProtocolAdapter.receivePackage:(ILjava/lang/SLjava/io/InputS)Z // method@0221Invokes method@221 interface method using parameters in v1,v3,v4 and v55.
私有方法用invoke-special,编译时,静态确定的。
&Java编译后class指令
Description: calls a special class method&n is the number of arguments to the method&the long method name is really a path name, the name of the class,the parenthesized argument list of the method called, and the return type.&Primitive types are represented by their capitalized first letter, ie I for an integer.&Constructors are path followed by &init&()V
returned value
object reference
Jasm-------------------
invoke packages/myMath/multiplyMatrix([[F, [[F)V &&&& ;multiplies two two-dimensional matrices of floats&
Exceptions
NullPointerException if object ref is null&StackOverflowError if you run ou t of room on stack
Description: calls a static method&n is the number of arguments to the method&the long method name is really a path name, the name of the class,the parenthesized argument list of the method called, and the return type.&Primitive types are represented by their capitalized first letter, ie I for an integer.&Constructors are path followed by &init&()V
returned value
Jasm-------------------
invoke java/lang/System/gc()V &&&& ;call the garbage collector
Exceptions
NullPointerException if object ref is null&StackOverflowError if you run ou t of room on stack
以下两则引用来自java文档,和android可能有差别:
7.7 Invoking Methods
The normal method invocation for a instance method dispatches on the runtime type of the object. (They are virtual, in C++ terms.) Such an invocation is implemented using the invokevirtual instruction, which takes as its argument an index to a runtime constant pool entry giving the fully qualified name of the class type of the object, the name of the method to invoke, and that method's descriptor&. To invoke the&addTwo&method, defined earlier as an instance method, we might write
int add12and13() {
return addTwo(12, 13);
This compiles to
Method int add12and13()
// Push local variable 0 (this)
// Push int constant 12
// Push int constant 13
invokevirtual #4
// Method Example.addtwo(II)I
// Return int on
// the int result of addTwo()
The invocation is set up by first pushing a&reference&to the current instance,&this, onto the operand stack. The method invocation's arguments,&int&values&12&and&13, are then pushed. When the frame for the&addTwo&method is created, the arguments passed to the method become the initial values of the new frame's local variables. That is, the&reference&for&this&and the two arguments, pushed onto the operand stack by the invoker, will become the initial values of local variables 0, 1, and 2 of the invoked method.
Finally,&addTwo&is invoked. When it returns, its&int&return value is pushed onto the operand stack of the frame of the invoker, the&add12and13&method. The return value is thus put in place to be immediately returned to the invoker of&add12and13.
The return from&add12and13&is handled by the ireturn instruction of&add12and13. The ireturn instruction takes the&int&value returned by&addTwo, on the operand stack of the current frame, and pushes it onto the operand stack of the frame of the invoker. It then returns control to the invoker, making the invoker's frame current. The Java virtual machine provides distinct return instructions for many of its numeric and&reference&data types, as well as a return instruction for methods with no return value. The same set of return instructions is used for all varieties of method invocations.
The operand of the invokevirtual instruction (in the example, the runtime constant pool index #4) is not the offset of the method in the class instance. The compiler does not know the internal layout of a class instance. Instead, it generates symbolic references to the methods of an instance, which are stored in the runtime constant pool. Those runtime constant pool items are resolved at run time to determine the actual method location. The same is true for all other Java virtual machine instructions that access class instances.
Invoking&addTwoStatic, a class (static) variant of&addTwo, is similar, as shown:
int add12and13() {
return addTwoStatic(12, 13);
although a different Java virtual machine method invocation instruction is used:
Method int add12and13()
invokestatic #3
// Method Example.addTwoStatic(II)I
Compiling an invocation of a class (static) method is very much like compiling an invocation of an instance method, except&this&is not passed by the invoker. The method arguments will thus be received beginning with local variable 0 (see&). The invokestatic instruction is always used to invoke class methods.
The invokespecial instruction must be used to invoke instance initialization methods (see&). It is also used when invoking methods in the superclass (super) and when invoking&private&methods. For instance, given classes&Near&and&Far&declared as
class Near {
public int getItNear() {
return getIt();
private int getIt() {
class Far extends Near {
int getItFar() {
return super.getItNear();
the method&Near.getItNear&(which invokes a&private&method) becomes
Method int getItNear()
invokespecial #5
// Method Near.getIt()I
The method&Far.getItFar&(which invokes a superclass method) becomes
Method int getItFar()
invokespecial #4
// Method Near.getItNear()I
Note that methods called using the invokespecial instruction always pass&this&to the invoked method as its first argument. As usual, it is received in local variable 0.
7.8 Working with Class Instances
Java virtual machine class instances are created using the Java virtual machine's new instruction. Recall that at the level of the Java virtual machine, a constructor appears as a method with the compiler-supplied name&&init&. This specially named method is known as the instance initialization method&. Multiple instance initialization methods, corresponding to multiple constructors, may exist for a given class. Once the class instance has been created and its instance variables, including those of the class and all of its superclasses, have been initialized to their default values, an instance initialization method of the new class instance is invoked. For example:
Object create() {
return new Object();
compiles to
Method java.lang.Object create()
// Class java.lang.Object
invokespecial #4
// Method java.lang.Object.&init&()V
Class instances are passed and returned (as&reference&types) very much like numeric values, although type&reference&has its own complement of instructions, for example:
// An instance variable
MyObj example() {
MyObj o = new MyObj();
return silly(o);
MyObj silly(MyObj o) {
if (o != null) {
Method MyObj example()
// Class MyObj
invokespecial #5
// Method MyObj.&init&()V
invokevirtual #4
// Method Example.silly(LMyO)LMyO
Method MyObj silly(MyObj)
The fields of a class instance (instance variables) are accessed using the getfield and putfield instructions. If&i&is an instance variable of type&int, the methods&setIt&and&getIt,&defined as
void setIt(int value) {
int getIt() {
Method void setIt(int)
putfield #4
// Field Example.i I
Method int getIt()
getfield #4
// Field Example.i I
As with the operands of method invocation instructions, the operands of the putfield and getfield instructions (the runtime constant pool index #4) are not the offsets of the fields in the class instance. The compiler generates symbolic references to the fields of an instance, which are stored in the runtime constant pool. Those runtime constant pool items are resolved at run time to determine the location of the field within the referenced object.
dex2jar后:
package com.dataviz.dxtg.common.
import android.app.A
import android.content.C
import android.content.res.R
import android.os.H
import com.dataviz.dxtg.common.android.e.g;
public class DocsToGoApp
extends Application
private static Application a = null;
private static bv b = null;
public DocsToGoApp()
public static Context a()
return a.getApplicationContext();
public static String a(String paramString)
int i = "x.xxx".length();
if (paramString.length() & i) {
paramString = paramString.substring(0, i);
return paramS
public static void a(Runnable paramRunnable)
new Handler(a().getMainLooper()).post(paramRunnable);
public static Resources b()
return a.getResources();
public static bv c()
if (b == null) {}
Thread.sleep(500L);
catch (Throwable localThrowable)
break label12;
public void onCreate()
g.a().a(getPackageName());
new Handler().postAtFrontOfQueue(new bu(this));
bv localbv = new bv(this);
localbv.a();
catch (Throwable localThrowable)
localThrowable.printStackTrace();
Bytecode for the Dalvik VMCopyright & 2007 The Android Open Source Project
General Design
The machine model and calling conventions are meant to approximately imitate common real architectures and C-style calling conventions:
The VM is register-based, and frames are fixed in size upon creation. Each frame consists of a particular number of registers (specified by the method) as well as any adjunct data needed to execute the method, such as (but not limited to) the program counter and a reference to the&.dex&file that contains the method.
Registers are 32 bits wide. Adjacent register pairs are used for 64-bit values.
In terms of bitwise representation,&(Object) null == (int) 0.
The&N&arguments to a method land in the last&N&registers of the method&s invocation frame, in order. Wide arguments consume two registers. Instance methods are passed a&this&reference as their first argument.
The storage unit in the instruction stream is a 16-bit unsigned quantity. Some bits in some instructions are ignored / must-be-zero.
Instructions aren&t gratuitously limited to a particular type. For example, instructions that move 32-bit register values without interpretation don&t have to specify whether they are moving ints or floats.
There are separately enumerated and indexed constant pools for references to strings, types, fields, and methods.
Bitwise literal data is represented in-line in the instruction stream.
Because, in practice, it is uncommon for a method to need more than 16 registers, and because needing more than eight registers&is&reasonably common, many instructions are limited to only addressing the first 16 registers. When reasonably possible, instructions allow references to up to the first 256 registers. In cases where an instruction variant isn&t available to address a desired register, it is expected that the register contents get moved from the original register to a low register (before the operation) and/or moved from a low result register to a high register (after the operation).
There are several &pseudo-instructions& that are used to hold variable-length data referred to by regular instructions (for example,&fill-array-data). Such instructions must never be encountered during the normal flow of execution. In addition, the instructions must be located on even-numbered bytecode offsets (that is, 4-byte aligned). In order to meet this requirement, dex generation tools should emit an extra&nop&instruction as a spacer if such an instruction would otherwise be unaligned. Finally, though not required, it is expected that most tools will choose to emit these instructions at the ends of methods, since otherwise it would likely be the case that additional instructions would be needed to branch around them.
When installed on a running system, some instructions may be altered, changing their format, as an install-time static linking optimization. This is to allow for faster execution once linkage is known. See the associated&&for the suggested variants. The word &suggested& it is not mandatory to implement these.
Human-syntax and mnemonics:
Dest-then-source ordering for arguments.
Some opcodes have a disambiguating suffix with respect to the type(s) they operate on: Type-general 64-bit opcodes are suffixed with&-wide. Type-specific opcodes are suffixed with their type (or a straightforward abbreviation), one of:&-boolean&-byte&-char&-short&-int&-long&-float&-double&-object&-string&-class&-void. Type-general 32-bit opcodes are unmarked.
Some opcodes have a disambiguating suffix to distinguish otherwise-identical operations that have different instruction layouts or options. These suffixes are separated from the main names with a slash (&/&) and mainly exist at all to make there be a one-to-one mapping with static constants in the code that generates and interprets executables (that is, to reduce ambiguity for humans).
See the&&for more details about the various instruction formats (listed under &Op & Format&) as well as details about the opcode syntax.
Summary of Instruction Set
Op & Format
Mnemonic / Syntax
Description
Waste cycles.
move vA, vB
A:&destination register (4 bits)B:&source register (4 bits)
Move the contents of one non-object register to another.
move/from16 vAA, vBBBB
A:&destination register (8 bits)B:&source register (16 bits)
Move the contents of one non-object register to another.
move/16 vAAAA, vBBBB
A:&destination register (16 bits)B:&source register (16 bits)
Move the contents of one non-object register to another.
move-wide vA, vB
A:&destination register pair (4 bits)B:&source register pair (4 bits)
Move the contents of one register-pair to another.
Note:&It is legal to move from&vN&to either&vN-1&or&vN+1, so implementations must arrange for both halves of a register pair to be read before anything is written.
move-wide/from16 vAA, vBBBB
A:&destination register pair (8 bits)B:&source register pair (16 bits)
Move the contents of one register-pair to another.
Note:&Implementation considerations are the same as&move-wide, above.
move-wide/16 vAAAA, vBBBB
A:&destination register pair (16 bits)B:&source register pair (16 bits)
Move the contents of one register-pair to another.
Note:&Implementation considerations are the same as&move-wide, above.
move-object vA, vB
A:&destination register (4 bits)B:&source register (4 bits)
Move the contents of one object-bearing register to another.
move-object/from16 vAA, vBBBB
A:&destination register (8 bits)B:&source register (16 bits)
Move the contents of one object-bearing register to another.
move-object/16 vAAAA, vBBBB
A:&destination register (16 bits)B:&source register (16 bits)
Move the contents of one object-bearing register to another.
move-result vAA
A:&destination register (8 bits)
Move the single-word non-object result of the most recent&invoke-kind&into the indicated register. This must be done as the instruction immediately after aninvoke-kind&whose (single-word, non-object) result
anywhere else is invalid.
move-result-wide vAA
A:&destination register pair (8 bits)
Move the double-word result of the most recent&invoke-kind&into the indicated register pair. This must be done as the instruction immediately after aninvoke-kind&whose (double-word) result
anywhere else is invalid.
move-result-object vAA
A:&destination register (8 bits)
Move the object result of the most recent&invoke-kind&into the indicated register. This must be done as the instruction immediately after an&invoke-kindor&filled-new-array&whose (object) result
anywhere else is invalid.
move-exception vAA
A:&destination register (8 bits)
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 must&only&ever occur as the first instruction of
anywhere else is invalid.
return-void
Return from a&void&method.
return vAA
A:&return value register (8 bits)
Return from a single-width (32-bit) non-object value-returning method.
return-wide vAA
A:&return value register-pair (8 bits)
Return from a double-width (64-bit) value-returning method.
return-object vAA
A:&return value register (8 bits)
Return from an object-returning method.
const/4 vA, #+B
A:&destination register (4 bits)B:&signed int (4 bits)
Move the given literal value (sign-extended to 32 bits) into the specified register.
const/16 vAA, #+BBBB
A:&destination register (8 bits)B:&signed int (16 bits)
Move the given literal value (sign-extended to 32 bits) into the specified register.
const vAA, #+BBBBBBBB
A:&destination register (8 bits)B:&arbitrary 32-bit constant
Move the given literal value into the specified register.
const/high16 vAA, #+BBBB0000
A:&destination register (8 bits)B:&signed int (16 bits)
Move the given literal value (right-zero-extended to 32 bits) into the specified register.
const-wide/16 vAA, #+BBBB
A:&destination register (8 bits)B:&signed int (16 bits)
Move the given literal value (sign-extended to 64 bits) into the specified register-pair.
const-wide/32 vAA, #+BBBBBBBB
A:&destination register (8 bits)B:&signed int (32 bits)
Move the given literal value (sign-extended to 64 bits) into the specified register-pair.
const-wide vAA, #+BBBBBBBBBBBBBBBB
A:&destination register (8 bits)B:&arbitrary double-width (64-bit) constant
Move the given literal value into the specified register-pair.
const-wide/high16 vAA, #+BBBB
A:&destination register (8 bits)B:&signed int (16 bits)
Move the given literal value (right-zero-extended to 64 bits) into the specified register-pair.
const-string vAA, string@BBBB
A:&destination register (8 bits)B:&string index
Move a reference to the string specified by the given index into the specified register.
const-string/jumbo vAA, string@BBBBBBBB
A:&destination register (8 bits)B:&string index
Move a reference to the string specified by the given index into the specified register.
const-class vAA, type@BBBB
A:&destination register (8 bits)B:&type index
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.
monitor-enter vAA
A:&reference-bearing register (8 bits)
Acquire the monitor for the indicated object.
monitor-exit vAA
A:&reference-bearing register (8 bits)
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 thrownafter&the instruction but&before&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.,&finally) block as the monitor cleanup for that block itself, as a way to handle the arbitrary exceptions that might get thrown due to the historical implementation ofThread.stop(), while still managing to have proper monitor hygiene.
check-cast vAA, type@BBBB
A:&reference-bearing register (8 bits)B:&type index (16 bits)
Throw a&ClassCastException&if the reference in the given register cannot be cast to the indicated type.
Note:&Since&A&must always be a reference (and not a primitive value), this will necessarily fail at runtime (that is, it will throw an exception) if&B&refers to a primitive type.
instance-of vA, vB, type@CCCC
A:&destination register (4 bits)B:&reference-bearing register (4 bits)C:&type index (16 bits)
Store in the given destination register&1&if the indicated reference is an instance of the given type, or&0&if not.
Note:&Since&B&must always be a reference (and not a primitive value), this will always result in&0&being stored if&C&refers to a primitive type.
array-length vA, vB
A:&destination register (4 bits)B:&array reference-bearing register (4 bits)
Store in the given destination register the length of the indicated array, in entries
new-instance vAA, type@BBBB
A:&destination register (8 bits)B:&type index
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.
new-array vA, vB, type@CCCC
A:&destination register (8 bits)B:&size registerC:&type index
Construct a new array of the indicated type and size. The type must be an array type.
filled-new-array {vD, vE, vF, vG, vA}, type@CCCC
B:&array size and argument word count (4 bits)C:&type index (16 bits)D..G, A:&argument registers (4 bits each)
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&long&or&double, but reference types are acceptable). The constructed instance is stored as a &result& in the same way that the method invocation instructions store their results, so the constructed instance must be moved to a register with an immediately subsequent&move-result-objectinstruction (if it is to be used).
filled-new-array/range {vCCCC .. vNNNN}, type@BBBB
A:&array size and argument word count (8 bits)B:&type index (16 bits)C:&first argument register (16 bits)N = A + C & 1
Construct an array of the given type and size, filling it with the supplied contents. Clarifications and restrictions are the same as&filled-new-array, described above.
fill-array-data vAA, +BBBBBBBB&(with supplemental data as specified below in &fill-array-data&Format&)
A:&array reference (8 bits)B:&signed &branch& offset to table data pseudo-instruction (32 bits)
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 must contain no more elements than will fit in the array. That is, the array may be larger than the table, and if so, only the initial elements of the array are set, leaving the remainder alone.
A:&exception-bearing register (8 bits)
Throw the indicated exception.
A:&signed branch offset (8 bits)
Unconditionally jump to the indicated instruction.
Note:&The branch offset must not be&0. (A spin loop may be legally constructed either with&goto/32&or by including a&nop&as a target before the branch.)
goto/16 +AAAA
A:&signed branch offset (16 bits)
Unconditionally jump to the indicated instruction.
Note:&The branch offset must not be&0. (A spin loop may be legally constructed either with&goto/32&or by including a&nop&as a target before the branch.)
goto/32 +AAAAAAAA
A:&signed branch offset (32 bits)
Unconditionally jump to the indicated instruction.
packed-switch vAA, +BBBBBBBB&(with supplemental data as specified below in &packed-switch&Format&)
A:&register to testB:&signed &branch& offset to table data pseudo-instruction (32 bits)
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.
sparse-switch vAA, +BBBBBBBB&(with supplemental data as specified below in &sparse-switch&Format&)
A:&register to testB:&signed &branch& offset to table data pseudo-instruction (32 bits)
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.
2d..31 23x
cmpkind&vAA, vBB, vCC2d: cmpl-float&(lt bias)2e: cmpg-float&(gt bias)2f: cmpl-double&(lt bias)30: cmpg-double&(gt bias)31: cmp-long
A:&destination register (8 bits)B:&first source register or pairC:&second source register or pair
Perform the indicated floating point or&long&comparison, storing&0&if the two arguments are equal,&1&if the second argument is larger, or&-1&if the first argument is larger. The &bias& listed for the floating point operations indicates how&NaNcomparisons are treated: &Gt bias& instructions return&1&for&NaN&comparisons, and &lt bias& instructions return&-1.
For example, to check to see if floating point&a & b, then it is advisable to usecmpg- a result of&-1&indicates that the test was true, and the other values indicate it was false either due to a valid comparison or because one or the other values was&NaN.
32..37 22t
if-test&vA, vB, +CCCC32: if-eq33: if-ne34: if-lt35: if-ge36: if-gt37: if-le
A:&first register to test (4 bits)B:&second register to test (4 bits)C:&signed branch offset (16 bits)
Branch to the given destination if the given two registers& values compare as specified.
Note:&The branch offset must not be&0. (A spin loop may be legally constructed either by branching around a backward&goto&or by including a&nop&as a target before the branch.)
38..3d 21t
if-testz vAA, +BBBB38: if-eqz39: if-nez3a: if-ltz3b: if-gez3c: if-gtz3d: if-lez
A:&register to test (8 bits)B:&signed branch offset (16 bits)
Branch to the given destination if the given register&s value compares with 0 as specified.
Note:&The branch offset must not be&0. (A spin loop may be legally constructed either by branching around a backward&goto&or by including a&nop&as a target before the branch.)
3e..43 10x
44..51 23x
arrayop&vAA, vBB, vCC44: aget45: aget-wide46: aget-object47: aget-boolean48: aget-byte49: aget-char4a: aget-short4b: aput4c: aput-wide4d: aput-object4e: aput-boolean4f: aput-byte50: aput-char51: aput-short
A:&va may be source or dest (8 bits)B:&array register (8 bits)C:&index register (8 bits)
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@CCCC52: iget53: iget-wide54: iget-object55: iget-boolean56: iget-byte57: iget-char58: iget-short59: iput5a: iput-wide5b: iput-object5c: iput-boolean5d: iput-byte5e: iput-char5f: iput-short
A:&va may be source or dest (4 bits)B:&object register (4 bits)C:&instance field reference index (16 bits)
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@BBBB60: sget61: sget-wide62: sget-object63: sget-boolean64: sget-byte65: sget-char66: sget-short67: sput68: sput-wide69: sput-object6a: sput-boolean6b: sput-byte6c: sput-char6d: sput-short
A:&va may be source or dest (8 bits)B:&static field reference index (16 bits)
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@CCCC6e: invoke-virtual6f: invoke-super70: invoke-direct71: invoke-static72: invoke-interface
B:&argument word count (4 bits)C:&method index (16 bits)D..G, A:&argument registers (4 bits each)
Call the indicated method. The result (if any) may be stored with an appropriatemove-result*&variant as the immediately subsequent instruction.
invoke-virtual&is used to invoke a normal virtual method (a method that is notstatic&or&final, and is not a constructor).
invoke-super&is used to invoke the closest superclass&s virtual method (as opposed to the one with the same&method_id&in the calling class).
invoke-direct&is used to invoke a non-static&direct method (that is, an instance method that is by its nature non-overridable, namely either a&privateinstance method or a constructor).
invoke-static&is used to invoke a&static&method (which is always considered a direct method).
invoke-interface&is used to invoke an&interface&method, that is, on an object whose concrete class isn&t known, using a&method_id&that refers to aninterface.
Note:&These opcodes are reasonable candidates for static linking, altering the method argument to be a more direct offset (or pair thereof).
74..78 3rc
invoke-kind/range {vCCCC .. vNNNN}, meth@BBBB74: invoke-virtual/range75: invoke-super/range76: invoke-direct/range77: invoke-static/range78: invoke-interface/range
A:&argument word count (8 bits)B:&method index (16 bits)C:&first argument register (16 bits)N = A + C & 1
Call the indicated method. See first&invoke-kind&description above for details, caveats, and suggestions.
79..7a 10x
7b..8f 12x
unop&vA, vB7b: neg-int7c: not-int7d: neg-long7e: not-long7f: neg-float80: neg-double81: int-to-long82: int-to-float83: int-to-double84: long-to-int85: long-to-float86: long-to-double87: float-to-int88: float-to-long89: float-to-double8a: double-to-int8b: double-to-long8c: double-to-float8d: int-to-byte8e: int-to-char8f: int-to-short
A:&destination register or pair (4 bits)B:&source register or pair (4 bits)
Perform the identified unary operation on the source register, storing the result in the destination register.
90..af 23x
binop&vAA, vBB, vCC90: add-int91: sub-int92: mul-int93: div-int94: rem-int95: and-int96: or-int97: xor-int98: shl-int99: shr-int9a: ushr-int9b: add-long9c: sub-long9d: mul-long9e: div-long9f: rem-longa0: and-longa1: or-longa2: xor-longa3: shl-longa4: shr-longa5: ushr-longa6: add-floata7: sub-floata8: mul-floata9: div-floataa: rem-floatab: add-doubleac: sub-doublead: mul-doubleae: div-doubleaf: rem-double
A:&destination register or pair (8 bits)B:&first source register or pair (8 bits)C:&second source register or pair (8 bits)
Perform the identified binary operation on the two source registers, storing the result in the first source register.
b0..cf 12x
binop/2addr vA, vBb0: add-int/2addrb1: sub-int/2addrb2: mul-int/2addrb3: div-int/2addrb4: rem-int/2addrb5: and-int/2addrb6: or-int/2addrb7: xor-int/2addrb8: shl-int/2addrb9: shr-int/2addrba: ushr-int/2addrbb: add-long/2addrbc: sub-long/2addrbd: mul-long/2addrbe: div-long/2addrbf: rem-long/2addrc0: and-long/2addrc1: or-long/2addrc2: xor-long/2addrc3: shl-long/2addrc4: shr-long/2addrc5: ushr-long/2addrc6: add-float/2addrc7: sub-float/2addrc8: mul-float/2addrc9: div-float/2addrca: rem-float/2addrcb: add-double/2addrcc: sub-double/2addrcd: mul-double/2addrce: div-double/2addrcf: rem-double/2addr
A:&destination and first source register or pair (4 bits)B:&second source register or pair (4 bits)
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, #+CCCCd0: add-int/lit16d1: rsub-int (reverse subtract)d2: mul-int/lit16d3: div-int/lit16d4: rem-int/lit16d5: and-int/lit16d6: or-int/lit16d7: xor-int/lit16
A:&destination register (4 bits)B:&source register (4 bits)C:&signed int constant (16 bits)
Perform the indicated binary op on the indicated register (first argument) and literal value (second argument), storing the result in the destination register.
Note:&rsub-int&does not have a suffix since this version is the main opcode of its family. Also, see below for details on its semantics.
d8..e2 22b
binop/lit8 vAA, vBB, #+CCd8: add-int/lit8d9: rsub-int/lit8da: mul-int/lit8db: div-int/lit8dc: rem-int/lit8dd: and-int/lit8de: or-int/lit8df: xor-int/lit8e0: shl-int/lit8e1: shr-int/lit8e2: ushr-int/lit8
A:&destination register (8 bits)B:&source register (8 bits)C:&signed int constant (8 bits)
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&rsub-int.
e3..ff 10x
packed-switch&Format
Description
ushort = 0x0100
identifying pseudo-opcode
number of entries in the table
first (and lowest) switch case value
list of&size&relative branch targets. The targets are relative to the address of the switch opcode, not of this table.
Note:&The total number of code units for an instance of this table is&(size * 2) + 4.
sparse-switch&Format
Description
ushort = 0x0200
identifying pseudo-opcode
number of entries in the table
list of&size&key values, sorted low-to-high
list of&size&relative branch targets, each corresponding to the key value at the same index. The targets are relative to the address of the switch opcode, not of this table.
Note:&The total number of code units for an instance of this table is&(size * 4) + 2.
fill-array-data&Format
Description
ushort = 0x0300
identifying pseudo-opcode
element_width
number of bytes in each element
number of elements in the table
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.
C Semantics
int32int32 result = -a;
Unary twos-complement.
int32int32 result = ~a;
Unary ones-complement.
int64int64 result = -a;
Unary twos-complement.
int64int64 result = ~a;
Unary ones-complement.
float result = -a;
Floating point negation.
neg-double
double result = -a;
Floating point negation.
int-to-long
int32int64 result = (int64)
Sign extension of&int32&into&int64.
int-to-float
int32float result = (float)
Conversion of&int32&to&float, using round-to-nearest. This loses precision for some values.
int-to-double
int32double result = (double)
Conversion of&int32&to&double.
long-to-int
int64int32 result = (int32)
Truncation of&int64&into&int32.
long-to-float
int64float result = (float)
Conversion of&int64&to&float, using round-to-nearest. This loses precision for some values.
long-to-double
int64double result = (double)
Conversion of&int64&to&double, using round-to-nearest. This loses precision for some values.
float-to-int
int32 result = (int32)
Conversion of&float&to&int32, using round-toward-zero.&NaN&and&-0.0&(negative zero) convert to the integer&0. Infinities and values with too large a magnitude to be represented get converted to either&0x7fffffff&or&-0x&depending on sign.
float-to-long
int64 result = (int64)
Conversion of&float&to&int64, using round-toward-zero. The same special case rules as for&float-to-int&apply here, except that out-of-range values get converted to either&0x7fffffffffffffff&or&-0x0000&depending on sign.
float-to-double
double result = (double)
Conversion of&float&to&double, preserving the value exactly.
double-to-int
int32 result = (int32)
Conversion of&double&to&int32, using round-toward-zero. The same special case rules as for&float-to-int&apply here.
double-to-long
int64 result = (int64)
Conversion of&double&to&int64, using round-toward-zero. The same special case rules as for&float-to-long&apply here.
double-to-float
float result = (float)
Conversion of&double&to&float, using round-to-nearest. This loses precision for some values.
int-to-byte
int32int32 result = (a && 24) && 24;
Truncation of&int32&to&int8, sign extending the result.
int-to-char
int32int32 result = a & 0
Truncation of&int32&to&uint16, without sign extension.
int-to-short
int32int32 result = (a && 16) && 16;
Truncation of&int32&to&int16, sign extending the result.
int32 a,int32 result = a +
Twos-complement addition.
int32 a,int32 result = a &
Twos-complement subtraction.
int32 a,int32 result = b &
Twos-complement reverse subtraction.
int32 a,int32 result = a *
Twos-complement multiplication.
int32 a,int32 result = a /
Twos-complement division, rounded towards zero (that is, truncated to integer). This throws&ArithmeticException&if&b == 0.
int32 a,int32 result = a %
Twos-complement remainder after division. The sign of the result is the same as that of&a, and it is more precisely defined as&result == a & (a / b) * b. This throws&ArithmeticException&if&b == 0.
int32 a,int32 result = a &
Bitwise AND.
int32 a,int32 result = a |
Bitwise OR.
int32 a,int32 result = a ^
Bitwise XOR.
int32 a,int32 result = a && (b & 0x1f);
Bitwise shift left (with masked argument).
int32 a,int32 result = a && (b & 0x1f);
Bitwise signed shift right (with masked argument).
uint32 a,int32 result = a && (b & 0x1f);
Bitwise unsigned shift right (with masked argument).
int64 a,int64 result = a +
Twos-complement addition.
int64 a,int64 result = a &
Twos-complement subtraction.
int64 a,int64 result = a *
Twos-complement multiplication.
int64 a,int64 result = a /
Twos-complement division, rounded towards zero (that is, truncated to integer). This throws&ArithmeticException&if&b == 0.
int64 a,int64 result = a %
Twos-complement remainder after division. The sign of the result is the same as that of&a, and it is more precisely defined as&result == a & (a / b) * b. This throws&ArithmeticException&if&b == 0.
int64 a,int64 result = a &
Bitwise AND.
int64 a,int64 result = a |
Bitwise OR.
int64 a,int64 result = a ^
Bitwise XOR.
int64 a,int64 result = a && (b & 0x3f);
Bitwise shift left (with masked argument).
int64 a,int64 result = a && (b & 0x3f);
Bitwise signed shift right (with masked argument).
uint64 a,int64 result = a && (b & 0x3f);
Bitwise unsigned shift right (with masked argument).
float a,float result = a +
Floating point addition.
float a,float result = a &
Floating point subtraction.
float a,float result = a *
Floating point multiplication.
float a,float result = a /
Floating point division.
float a,float result = a %
Floating point remainder after division. This function is different than IEEE 754 remainder and is defined as&result == a & roundTowardZero(a / b) * b.
add-double
double a,double result = a +
Floating point addition.
sub-double
double a,double result = a &
Floating point subtraction.
mul-double
double a,double result = a *
Floating point multiplication.
div-double
double a,double result = a /
Floating point division.
rem-double
double a,double result = a %
Floating point remainder after division. This function is different than IEEE 754 remainder and is defined as&result == a & roundTowardZero(a / b) * b.
Dalvik opcodes
http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html
Dalvik opcodes
Vx values in the table denote a Dalvik register. Depending on the instruction, 16, 256 or 64k registers can be accessed. Operations on long and double values use two registers, e.g. a double value addressed in the V0 register occupies the V0 and V1 registers.
Boolean values are stored as 1 for true and 0 for false. Operations on booleans are translated into integer operations.
All the examples are in hig-endian format, e.g. 0F00 0A00 is coded as&0F, 00, 0A, 00 sequence.
Note there are no explanation/example at some instructions. This means that I have not seen that instruction &in the wild& and its presence/name is only known from&.
Opcode (hex)
Opcode name
Explanation
No operation
0000 & nop
move vx,vy
Moves the content of vy into vx. Both registers must be in the first 256 register range.
0110 & move v0, v1Moves v1 into v0.
move/from16 vx,vy
Moves the content of vy into vx. vy may be in the 64k register range while vx is one of the first 256 registers.
& move/from16 v0, v25Moves v25 into v0.
move-wide/from16 vx,vy
Moves a long/double value from vy to vx. vy may be in the 64k register range while wx is one of the first 256 registers.
& move-wide/from16 v22, v0Moves v0 into v22.
move-wide/16
move-object vx,vy
Moves the object reference from vy to vx.
0781 & move-object v1, v8Moves the object reference in v8 to v1.
move-object/from16 vx,vy
Moves the object reference from vy to vx, vy can address 64k registers and vx can address 256 registers.
& move-object/from16 v1, v21Move the object reference in v21 to v1.
move-object/16
move-result vx
Move the result value of the previous method invocation into vx.
0A00 & move-result v0Move the return value of a previous method invocation into v0.
move-result-wide vx
Move the long/double result value of the previous method invocation into vx,vx+1.
0B02 & move-result-wide v2Move the long/double result value of the previous method invocation into v2,v3.
move-result-object vx
Move the result object reference of the previous method invocation into vx.
0C00 & move-result-object v0
move-exception vx
Move the exception object reference thrown during a method invocation into vx.
0D19 & move-exception v25
return-void
Return without a return value
0E00 & return-void
Return with vx return value
0F00 & return v0Returns with return value in v0.
return-wide vx
Return with double/long result in vx,vx+1.
1000 & return-wide v0Returns with a double/long value in v0,v1.
return-object vx
Return with vx object reference value.
1100 & return-object v0Returns with object reference value in v0
const/4 vx,lit4
Puts the 4 bit constant into vx
1221 & const/4 v1, #int2Moves literal 2 into v1. The destination register is in the lower 4 bit in the second byte, the literal 2 is in the higher 4 bit.
const/16 vx,lit16
Puts the 16 bit constant into vx
& const/16 v0, #int 10Puts the literal constant of 10 into v0.
const vx, lit32
Puts the integer constant into vx
BC00 & const v0, #&&&&&&&&&&&&&&&&&&&// #00BC614EMoves literal&&&&&&&&&&&&&&&&&&&&into v0.
const/high16 v0, lit16
Puts the 16 bit constant into the topmost bits of the register. Used to initialize float values.
&&&&&&&& const/high16 v0, #float 10.0 // #Moves the floating literal of 10.0 into v0. The 16 bit literal in the instruction carries the top 16 bits of the floating point number.
const-wide/16 vx, lit16
Puts the integer constant into vx and vx+1 registers, expanding the integer constant into a long constant..
& const-wide/16 v0, #long 10Moves literal 10 into v0 and v1 registers.
const-wide/32 vx, lit32
Puts the 32 bit constant into vx and vx+1 registers, expanding the integer constant into a long constant.
bc00 & const-wide/32 v2, #long&&&&&&&&&&&&&&&&&&&&// #00bc614ePuts #&&&&&&&&&&&&&&&&&&&into v2 and v3 registers.
const-wide vx, lit64
Puts the 64 bit constant into vx and vx+1 registers.
b5d 54dc 2b00- const-wide v2, #long 34567 // #002bdc545d6b4b87Puts #34567 into v2 and v3 registers.
const-wide/high16 vx,lit16
Puts the 16 bit constant into the highest 16 bit of vx and vx+1 registers. Used to initialize double values.
&&&&&&&& const-wide/high16 v0, #double 10.0 // #Puts the double constant of 10.0 into v0 register.
const-string vx,string_id
Puts reference to a string constant identified by string_id into vx.
1A08 0000 & const-string v8, && // string@0000Puts reference to string@0000 (entry #0 in the string table) into v8.
const-string-jumbo
const-class vx,type_id
Moves the class object of a class identified by type_id (e.g. Object.class) into vx.
1C00 0100 & const-class v0, Test3 // type@0001Moves reference to Test3.class (entry#1 in the type id table) into
monitor-enter vx
Obtains the monitor of the object referenced by vx.
1D03 & monitor-enter v3Obtains the monitor of the object referenced by v3.
monitor-exit
Releases the monitor of the object referenced by vx.
1E03 & monitor-exit v3Releases the monitor of the object referenced by v3.
check-cast vx, type_id
Checks whether the object reference in vx can be cast to an instance of a class referenced by type_id. Throws ClassCastException if the cast is not possible, continues execution otherwise.
1F04 0100 & check-cast v4, Test3 // type@0001Checks whether the object reference in v4 can be cast to type@0001 (entry #1 in the type id table)
instance-of vx,vy,type_id
Checks whether vy is instance of a class identified by type_id. Sets vx non-zero if it is, 0 otherwise.
& instance-of v0, v4, Test3 // type@0001Checks whether the object reference in v4 is an instance of type@0001 (entry #1 in the type id table). Sets v0 to non-zero if v4 is instance of Test3, 0 otherwise.
array-length vx,vy
Calculates the number of elements of the array referenced by vy and puts the length value into vx.
2111 & array-length v1, v1Calculates the number of elements of the array referenced by v1 and puts the result into v1.
new-instance vx,type
Instantiates an object type and puts the reference of the newly created instance into vx.
&&&&&&&& new-instance v0, java.io.FileInputStream // type@0015Instantiates type@0015 (entry #15H in the type table) and puts its reference into v0.
new-array vx,vy,type_id
Generates a new array of type_id type and vy element size and puts the reference to the array into vx.
&&&&&&&& new-array v2, v1, char[] // type@0025Generates a new array of type@0025 type and v1 size and puts the reference to the new array into v2.
filled-new-array {parameters},type_id
Generates a new array of type_id and fills it with the parameters5. Reference to the newly generated array can be obtained by a move-result-object instruction, immediately following the filled-new-array instruction.
00 & filled-new-array {v0,v0},[I // type@0D53Generates a new array of type@0D53. The array&s size will be 2 and both elements will be filled with the contents of v0 register.
filled-new-array-range {vx..vy},type_id
Generates a new array of type_id and fills it with a range of parameters. Reference to the newly generated array can be obtained by a move-result-object instruction, immediately following the filled-new-array instruction.
00 & filled-new-array/range {v19..v21}, [B // type@0006Generates a new array of type@0D53. The array&s size will be 3 and the elements will be filled using the v19,v20 and v21 registers4.
fill-array-data vx,array_data_offset
Fills the array referenced by vx with the static data. The location of the static data is the sum of& the position of the current instruction and the offset
00 & fill-array-data v6, 00e6 // +0025Fills the array referenced by v0 with the static data at current instruction+25H words location. The offset is expressed as a 32-bit number. The static data is stored in the following format:0003 // Table type: static array data0400 // Byte per array element (in this case, 4 byte integers) // Number of elements in the table& // Element #0: integer 1 // Element #1: integer 2 // Element #2: integer3
Throws an exception object. The reference of the exception object is in vx.
2700 & throw v0Throws an exception. The exception object reference is in v0.
goto target
Unconditional jump by short offset2.
28F0 & goto 0005 // -0010Jumps to current position-16 words (hex 10). 0005 is the label of the target instruction.
goto/16 target
Unconditional jump by 16 bit offset2.
2900 0FFE & goto/16 002f // -01f1Jumps to the current position-1F1H words. 002F is the label of the target instruction.
goto/32 target
packed-switch vx,table
Implements a switch statement where the case constants are close to each other. The instruction uses an index table. vx indexes into this table to find the offset of the instruction for a particular case. If vx falls out of the index table, the execution continues on the next instruction (default case).
2B02 0C00 0000 & packed-switch v2, 000c // +000cExecute a packed switch according to the switch argument in v2. The position of the index table is at current instruction+0CH words. The table looks like the following:0001 // Table type: packed switch table0300 // number of elements // element base& 0:
// case 0: +& 1:
// case 1: +& 2:
// case 2: +
sparse-switch vx,table
Implements a switch statement with sparse case table. The instruction uses a lookup table with case constants and offsets for each case constant. If there is no match in the table, execution continues on the next instruction (default case).
2C02 0c00 0000 & sparse-switch v2, 000c // +000cExecute a sparse switch according to the switch argument in v2. The position of the lookup table is at current instruction+0CH words. The table looks like the following.0002 // Table type: sparse switch table0300 // number of elements9cff ffff // first case: -100fa00 0000 // second case constant: 250e803 0000 // third case constant: 1000 // offset for the first case constant: +5 // offset for the second case constant: +7 // offset for the third case constant: +9
cmpl-float
Compares the float values in vy and vz and sets the integer value in vx accordingly3
2D00 0607 & cmpl-float v0, v6, v7Compares the float values in v6 and v7 then sets v0 accordingly. NaN bias is less-than, the instruction will return -1 if any of the parameters is NaN.
cmpg-float vx, vy, vz
Compares the float values in vy and vz and sets the integer value in vx accordingly3.
2E00 0607 & cmpg-float v0, v6, v7Compares the float values in v6 and v7 then sets v0 accordingly. NaN bias is greater-than, the instruction will return 1 if any of the parameters is NaN.
cmpl-double vx,vy,vz
Compares the double values in vy and vz2&and sets the integer value in vx accordingly3.
2F19 0608 & cmpl-double v25, v6, v8Compares the double values in v6,v7 and v8,v9 and sets v25 accordingly. NaN bias is less-than, the instruction will return -1 if any of the parameters is NaN.
cmpg-double vx, vy, vz
Compares the double values in vy and vz2&and sets the integer value in vx accordingly3.
A & cmpg-double v0, v8, v10Compares the double values in v8,v9 and v10,v11 then sets v0 accordingly. NaN bias is greater-than, the instruction will return 1 if any of the parameters is NaN.
cmp-long vx, vy, vz
Compares the long values in vy and vz and sets the integer value in vx accordingly3.
& cmp-long v0, v2, v4Compares the long values in v2 and v4 then sets v0 accordingly.
if-eq vx,vy,target
Jumps to target if vx==vy2. vx and vy are integer values.
32b3 6600 & if-eq v3, v11, 0080 // +0066Jumps to the current position+66H words if v3==v11. 0080 is the label of the target instruction.
if-ne vx,vy,target
Jumps to target if vx!=vy2. vx and vy are integer values.
33A3 1000 & if-ne v3, v10, 002c // +0010Jumps to the current position+10H words if v3!=v10. 002c is the label of the target instruction.
if-lt vx,vy,target
Jumps to target is vx&vy2. vx and vy are integer values.
3432 CBFF & if-lt v2, v3, 0023 // -0035Jumps to the current position-35H words if v2&v3. 0023 is the label of the target instruction.
if-ge vx, vy,target
Jumps to target if vx&=vy2. vx and vy are integer values.
& if-ge v0, v1, 002b // +001bJumps to the current position+1BH words if v0&=v1. 002b is the label of the target instruction.
if-gt vx,vy,target
Jumps to target if vx&vy2. vx and vy are integer values.
& if-ge v0, v1, 002b // +001bJumps to the current position+1BH words if v0&v1. 002b is the label of the target instruction.
if-le vx,vy,target
Jumps to target if vx&=vy2. vx and vy are integer values.
& if-le v6, v5, 0144 // +000bJumps to the current position+0BH words if v6&=v5. 0144 is the label of the target instruction.
if-eqz vx,target
Jumps to target if vx==02. vx is an integer value.
& if-eqz v2, 0038 // +0019Jumps to the current position+19H words if v2==0. 0038 is the label of the target instruction.
if-nez vx,target
Checks vx and jumps if vx is nonzero2.
& if-nez v2, 0014 // +0012Jumps to current position+18 words (hex 12) if v2 is nonzero. 0014 is the label of the target instruction.
if-ltz vx,target
Checks vx and jumps if vx&02.
3A00 1600 & if-ltz v0, 002d // +0016Jumps to the current position+16H words if v0&0. 002d is the label of the target instruction.
if-gez vx,target
Checks vx and jumps if vx&=02.
3B00 1600 & if-gez v0, 002d // +0016Jumps to the current position+16H words if v0 &=0. 002d is the label of the target instruction.
if-gtz vx,target
Checks vx and jumps if vx&02.
3C00 1D00 & if-gtz v0, 004a // +001dJumps to the current position+1DH words if v0&0. 004A is the label of the target instruction.
if-lez vx,target
Checks vx and jumps if vx&=02.
3D00 1D00 & if-lez v0, 004a // +001dJumps to the current position+1DH words if v0&=0. 004A is the label of the target instruction.
aget vx,vy,vz
Gets an integer value of an object reference array into vx. The array is referenced by vy and is indexed by vz.
&&&&&&&& aget v7, v3, v6Gets an integer array element. The array is referenced by v3 and the element is indexed by v6. The element will be put into v7.
aget-wide vx,vy,vz
Gets a long/double value of long/double array into vx,vx+1. The array is referenced by vy and is indexed by vz.
&&&&&&&& aget-wide v5, v1, v4Gets a long/double array element. The array is referenced by v1 and the element is indexed by v4. The element will be put into v5,v6.
aget-object vx,vy,vz
Gets an object reference value of an object reference array into vx. The array is referenced by vy and is indexed by vz.
&&&&&&&& aget-object v2, v2, v0Gets an object reference array element. The array is referenced by v2 and the element is indexed by v0. The element will be put into v2.
aget-boolean vx,vy,vz
Gets a boolean value of a boolean array into vx. The array is referenced by vy and is indexed by vz.
&&&&&&&& aget-boolean v0, v0, v1Gets a boolean array element. The array is referenced by v0 and the element is indexed by v1. The element will be put into v0.
aget-byte vx,vy,vz
Gets a byte value of a byte array into vx. The array is referenced by vy and is indexed by vz.
&&&&&&&& aget-byte v0, v0, v1Gets a byte array element. The array is referenced by v0 and the element is indexed by v1. The element will be put into v0.
aget-char vx, vy,vz
Gets a char value& of a character array into vx. The element is indexed by vz, the array object is referenced by vy
&&&&&&&& aget-char v5, v0, v3Gets a character array element. The array is referenced by v0 and the element is indexed by v3. The element will be put into v5.
aget-short vx,vy,vz
Gets a short value& of a short array into vx. The element is indexed by vz, the array object is referenced by vy.
4A00 0001 & aget-short v0, v0, v1Gets a short array element. The array is referenced by v0 and the element is indexed by v1. The }

我要回帖

更多关于 gt i8190n 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信