Smali language is actually the register language of Davlik;
The Smali language is the Android app. The APK is compiled with a Smali folder in Apktool, which is a file that ends in. Smali, and the file's display language.
The Smali syntax is briefly described as follows :
Davlik bytecode, registers are 32-bit, can support any type, 64-bit type (long/double) is represented by 2 registers;
There are two types of Dalvik bytecode: primitive type; reference type (including objects and arrays)
Primitive Type:v void can only be used for return value types
Z Boolean
B byte
S Short
C Char
I int
J Long (64-bit)
F float
D double (64-bit)
Object type : Lpackage/name/objectname; Equivalent to Package.name.ObjectName in Java, as explained below:
L: Indicates that this is an object type
Package/name: The package in which the object resides
;: Indicates the end of the object name
representation of the array:
[I : Represents a shaped one-dimensional array, equivalent to the Java int[];
for multidimensional arrays, just add [ on the line,[I = int[]; note: A maximum of 255 per dimension;
Representation of an array of objects:
[Ljava/lang/string represents an array of objects of a String;
Representation of the method:
lpackage/name/objectname;-->methodname (III) Z is detailed below:
Lpackage/name/objectname expression type
MethodName represents the method name
III represents the parameter (represented here as 3 integer parameters)
Note: The parameters of the method are one after the other, the middle is not separated;
representation of a field:
lpackage/name/objectname;-->fieldname:ljava/lang/string;
That means: Package name, field name, and field type
There are two ways to specify how many registers are available in a method:
The. Registers directive specifies the total number of registers in the method
The. Locals instruction shows the total number of non-parameter registers in the method, appearing in the first line of the method
Parameter of the method:
When a method is called, the parameters of the method are placed in the last n registers;
For example, a method has 2 parameters, 5 registers (V0~V4)
Then, the parameter will be placed in the last 2 registers (V3 and V4)
The first parameter in a non-static method always calls the object of the method;
Description: For static methods other than the implied this parameter, the others are the same
How registers are named:
V naming
P Naming the first register is the first parameter register in a method
Comparison: The use of the P name is to prevent later if the register is added in the method, it is necessary to re-numbering the parameter register disadvantage
In particular: long and double types are 64-bit and require 2 registers
For example, for non-static methods
Lmyobject-->mymethod (IJZ) V;
There are 4 parameters: Lmyobject,int,long,bool; 5 registers are required to store the parameters;
P0 this
P1 I (int)
P2,P3 J (Long)
P4 Z (BOOL)
A brief introduction to Smali syntax