Type
V void can only be used for the return value type
Z Boolean
B byte
S short
C char
I int
J long 2 registers
F float
D double two registers
Object Type: lpackage/name/objectname; equivalent to package. Name. objectname in Java; explanation:
L: indicates that this is an object type.
Package/Name: Package of the object
;: Indicates the end of the Object Name
Array representation:
[I: represents an integer one-dimensional array, equivalent to the Java int [];
For multi-dimensional arrays, just add [, [[I = int [] []; Note: A maximum of 255 values can be added to each dimension;
Object array representation:
[Ljava/lang/string indicates a String object array;
Method call representation:
Lpackage/name/objectname; --> methodname (iii) Z:
Lpackage/name/objectname indicates the type
Methodname indicates the method name.
III indicates parameters (three Integer Parameters here)
Note: The parameters of the method are one by one and are not separated between them;
Method (I [[I ljava/lang/string; [ljava/lang/object;) ljava/lang/string;
In Java:
String method (INT, int [] [], Int, String, object [])
Field representation:
Lpackage/name/objectname; --> fieldname: ljava/lang/string;
Indicates the package name, field name, and field type.
There are two ways to specify how many registers are available in a method:
The. Registers command specifies the total number of registers in the method.
The. Locals Instruction indicates the total number of non-parameter registers in the method, and the first line appears in the method.
Parameter passing for the method:
When a method is called, The method parameters are placed in the last n registers. If a method has 2 parameters, 5 registers (v0-v4), the parameters are placed in the last 2 registers-V3 and V4. The first parameter in a non-static method always calls the object of this method.
For example, the non-static method lmyobject;-> callme (ii) V has two Integer Parameters and an implicit lmyobject parameter. Therefore, there are three parameters in total. If five registers (v0-v4) are specified in this method. the registers method specifies five or. specify two local registers and three parameter registers in locals mode ). When this method is called, the object (that is, this reference) that calls this method is stored in V2, and the first integer parameter is stored in V3, the second integer parameter is stored in V4.
Register naming:
V name
P: The first register is the first parameter register in the method.
Comparison: P naming is used to prevent the disadvantage of re-numbering the parameter registers if registers are added in the method in the future.
Note: The long and double types are 64-bit, and two registers are required.
For example, for non-static methods
Lmyobject --> mymethod (ijz) V;
There are four parameters: lmyobject, Int, long, bool; five registers are required to store parameters;
P0 this
P1 I (INT)
P2, P3 J (long)
P4 Z (bool)
Supplement:
@ Static fields: Mark a static variable
@ Instance fields defines the tag of instance variables
@ Direct methods: Mark a static method
@ Virtual Methods: Mark a non-static method
The return type of the constructor is V and its name is <init>.
If-EQ P1, V0,: cond8 indicates that if P1 and V0 are equal, the cond8 process is executed:
: Cond8
Invoke-Direct {P0}, lcom/Paul/test/a;-> D () V
Call the D () method of COM. Paul. test..
If-ne P1, V0,: condb indicates that the condb process is executed if they are not equal:
: Condb
Invoke-Direct {P0}, lcom/Paul/test/a;-> C () V
Syntax in smali