Stack and local variable operation instructions

Source: Internet
Author: User

Instructions to press constants into the stack

Aconst_null to press the null object reference into the stack
ICONST_M1 pressing the int type constant-1 into the stack
ICONST_0 pressing the int type constant 0 into the stack
iconst_1 pressing the int type constant 1 into the stack
Iconst_2 pressing the int type constant 2 into the stack
Iconst_3 pressing the int type constant 3 into the stack
Iconst_4 pressing the int type constant 4 into the stack
Iconst_5 pressing the int type constant 5 into the stack
Lconst_0 pressing a long type constant 0 into the stack
Lconst_1 pressing a long type constant 1 into the stack
Fconst_0 pressing float type constant 0 into the stack
fconst_1 pressing float type constant 1 into the stack
Dconst_0 pressing the double type constant 0 into the stack
Dconst_1 pressing the double type constant 1 into the stack
Bipush pressing a 8-bit signed integer into the stack
Sipush 16-bit signed integers into the stack
LDC pushes items in the constant pool into the stack
Ldc_w pressing items in a constant pool into the stack (using a wide index)
Ldc2_w pressing a long or double item in a constant pool into the stack (using a wide index)

Instructions for loading values from local variables in the stack

Iload loading an int type value from a local variable
Lload loading a long type value from a local variable
Fload loading a float type value from a local variable
Dload loading a double type value from a local variable
Aload loading a reference type value from a local variable (refernce)
Iload_0 loading int type values from local variable 0
iload_1 loading int type values from local variable 1
iload_2 loading int type values from local variable 2
iload_3 loading int type values from local variable 3
Lload_0 loading a long type value from local variable 0
Lload_1 loading a long type value from local variable 1
Lload_2 loading a long type value from local variable 2
Lload_3 loading a long type value from local variable 3
Fload_0 loading float type value from local variable 0
Fload_1 loading float type value from local variable 1
Fload_2 loading float type value from local variable 2
Fload_3 loading float type value from local variable 3
Dload_0 loading a double type value from a local variable of 0
Dload_1 loading a double type value from a local variable of 1
Dload_2 loading a double type value from a local variable of 2
Dload_3 loading a double type value from a local variable of 3
Aload_0 loading a reference type value from a local variable of 0
Aload_1 loading a reference type value from a local variable of 1
Aload_2 loading a reference type value from a local variable of 2
Aload_3 loading a reference type value from a local variable of 3
Iaload loading an int type value from an array
Laload loading a long type value from an array
Faload loading float type values from an array
Daload loading a double type value from an array
Aaload loading reference type values from an array
Baload loading a byte type or Boolean value from an array
Caload loading char type values from an array
Saload loading short type values from an array

Instructions for storing values in the stack as local variables

Istore the value of type int to a local variable
Lstore a Long value into a local variable
Fstore The value of float type to local variable
Dstore the value of double type to local variable
Astore Place a reference type or ReturnAddress type value into a local variable
Istore_0 the value of type int to local variable 0
istore_1 save int type value to local variable 1
istore_2 type int value into local variable 2
Istore_3 the value of type int to local variable 3
Lstore_0 The Long value to local variable 0
Lstore_1 The Long value into local variable 1
lstore_2 the Long value into the local variable 2
Lstore_3 a Long value into local variable 3
Fstore_0 the float type value to local variable 0
Fstore_1 The value of float type to local variable 1
fstore_2 Save float type value to local variable 2
fstore_3 float type value to local variable 3
Dstore_0 save double type value to local variable 0
Dstore_1 save double type value to local variable 1
Dstore_2 a double type value into a local variable of 2
Dstore_3 the value of a double type to local variable 3
Astore_0 the reference type or ReturnAddress type value into the local variable 0
Astore_1 Save the reference type or ReturnAddress type value to local variable 1
astore_2 the reference type or ReturnAddress type value into the local variable 2
Astore_3 Saving a reference type or ReturnAddress type value to a local variable 3
Iastore the value of type int into an array
Lastore storing a Long value in an array
Fastore storing the value of type float in an array
Dastore the value of a double type into an array
Aastore the reference type value into the array
Bastore the byte type or Boolean value into the array
Castore in the array with the Char type value
Sastore the short type value into the array

Wide directive

Wide using additional bytes to extend the local variable index

Universal (no type) stack operation

NOP does not do any action
Pop pop-up stack at the top of a word-length content
POP2 pop-up stack top two word length content
DUP the top of the copy stack a word length content
Dup_x1 the top of the copy stack with a word length, and then press the contents of the copied content and the two words that originally popped into the stack
Dup_x2 the top of the copy stack with a word length, and then press the contents of the copied content and the three words that originally popped into the stack
DUP2 two word length content on top of copy stack
DUP2_X1 Copy the top of the stack of two words, and then copy the content and the original pop-up of three words into the stack
DUP2_X2 Copy the top of the stack of two words, and then copy the content and the original pop-up of four words into the stack
Swap stack top two word length content

Type conversions

I2L converts data of type int to type long
I2F convert data of type int to float type
i2d convert data of type int to double type
L2i converting a long type of data to an int type
L2F converting a long type of data to float type
L2d converting a long type of data to a double type
F2i conversion of float type data to int type
F2L converting float type data to type long
F2d converting float type data to double type
D2i converting a double type of data to an int type
D2L converting a double type of data to a long type
D2F converting a double type of data into a float type
I2B convert data of type int to byte type
I²c converts data of type int to char type
I2S convert data of type int to short type

Integer arithmetic

Iadd performing an addition of type int
Ladd performing a long type of addition
Isub performing subtraction of type int
Lsub performing a long type of subtraction
Imul performing multiplication of type int
Lmul performing a long type of multiplication
Idiv to perform division of type int
Ldiv performing a long type of division
Irem computes the remainder of the INT type division
Lrem calculating the remainder of a long type of division
Ineg to reverse an int type value
Lneg the inverse of a long type value
Iinc to add a constant value to a local variable of type int

Logical Operation SHIFT Operation

ISHL performing a left shift operation of type int
LSHL performing a long-type left shift operation
Ishr performing a right shift operation of type int
Lshr performing a long-type right shift operation
Iushr performing a right-shift operation of type int
Lushr performing a long-type right-shift operation

Bitwise Boolean Operations

Iand "Logical AND" operations on int type values
Land the "logical and" operation of a long type value
The IOR "logical" or "operation" of the Int type value
Lor a "logical or" operation on a long type value
Ixor a "logical XOR" operation on an int type value
Lxor a "logical XOR" operation on a long type value

Floating point Arithmetic

Fadd performing addition of float type
Dadd performing the addition of a double type
Fsub performing a type of float subtraction
Dsub performing a double type of subtraction
Fmul performing multiplication of type float
Dmul performing multiplication of double types
Fdiv performing a float type of division
Ddiv performing a double type of division
Frem calculates the remainder of a float type division
Drem computes the remainder of a double type division
Fneg to reverse the value of a float type
Dneg to reverse a numeric value of a double type

Object and Array Object manipulation directives

New creates an object
Checkcast determines whether the object is of the given type
GetField getting a field from an object
Putfield setting the value of a field in an object
Getstatic getting static fields from a class
Putstatic setting the value of a static field in a class
Instanceof Determines whether the object is of the given type

Array manipulation directives

NewArray assigning data member types to a new array of essentially data types
Anewarray assigning data member types to a new array of reference types
Arraylength getting the array length
Multianewarray Assigning a new multidimensional array

Control flow Condition Branch Instruction

ifeq if equal to 0, then jump
Ifne if not equal to 0, then jump
Iflt if it is less than 0, jump
IFGE if it is greater than or equal to 0, jump
IFGT if it is greater than 0, jump
Ifle if it is less than or equal to 0, jump
IF_ICMPCQ if two int values are equal, jump
If_icmpne if the values of the two int types are not equal, the jump
IF_ICMPLT if an int type value is less than the value of another int type, the jump
IF_ICMPGE if an int type value is greater than or equal to another int type value, the jump
IF_ICMPGT if an int type value is greater than the value of another int type, the jump
if_icmple if an int type value is less than or equal to another int type value, the jump
ifnull if equal to NULL, the jump
Ifnonnull if not equal to NULL, the jump
If_acmpeq If two object references are equal, jump
IF_ACMPNC If two object references are not equal, a jump

Compare directives

lcmp
Compare long type values
Fcmpl
Compares a float type value (returns 1 when Nan is encountered)
Fcmpg
Compares a float type value (returns 1 when Nan is encountered)
Dcmpl
Compares a double type value (returns 1 when Nan is encountered)
Dcmpg
Compares a double type value (returns 1 when Nan is encountered)

Unconditional Transfer Instructions

Goto
Unconditional Jump
Goto_w
Unconditional jump (Wide index)

Table Jump Instruction

Tableswitch
Access the jump table by index and jump
Lookupswitch
Access the jump table by key-value matching and perform a jump

Operation exception

Athrow throwing an exception or error finally clause
JSR Jump to subroutine
Jsr_w jump to subroutine (wide index)
RCT returns method call and return method call instruction from subroutine
The Invokcvirtual runtime invokes an instance method according to the class of the object
Invokespecial invoking instance methods based on compile-time type
Invokestatic call Class (Static) method
Invokcinterface calling interface Method method return instruction
Ireturn returning data of type int from a method
Lreturn returning a long type of data from a method
Freturn returning data of type float from a method
Dreturn returning a double type of data from a method
Areturn returning data from a method from a reference type
Return returned from the method with a return value of void

Thread synchronization

Montiorenter Enter and get Object monitor
Monitorexit releasing and exiting the object monitor

JVM instruction Mnemonic

Variable-to-operand stack: iload,iload_<n>,lload,lload_<n>,fload,fload_<n>,dload,dload_<n>,aload,aload_ <n>
operand stack to variable: istore,istore_<n>,lstore,lstore_<n>,fstore,fstore_<n>,dstore,dstor_<n>,astore, Astore_<n>
Constant to operand stack: bipush,sipush,ldc,ldc_w,ldc2_w,aconst_null,iconst_ml,iconst_<i>,lconst_<l>,fconst_<f >,dconst_<d>
Add: Iadd,ladd,fadd,dadd
Minus: Isub,lsub,fsub,dsub
Multiply: Imul,lmul,fmul,dmul
Except: Idiv,ldiv,fdiv,ddiv
Remainder: Irem,lrem,frem,drem
Take negative: Ineg,lneg,fneg,dneg
Shift: ISHL,LSHR,IUSHR,LSHL,LSHR,LUSHR
Bitwise OR: Ior,lor
Bitwise VS: Iand,land
Bitwise XOR: Ixor,lxor
Type conversions: i2l,i2f,i2d,l2f,l2d,f2d (relaxed numeric conversions) i2b,i2c,i2s,l2i,f2i,f2l,d2i,d2l,d2f (narrowing numeric conversions)
Create a class-by-fact: New
Create a new array: Newarray,anewarray,multianwarray
Accessing the domain and class instance domain of a class: Getfield,putfield,getstatic,putstatic
Loading data into the operand stack: baload,caload,saload,iaload,laload,faload,daload,aaload
Save from operand stack to array: Bastore,castore,sastore,iastore,lastore,fastore,dastore,aastore
Get array Length: arraylength
To check a similar instance or array property: Instanceof,checkcast
Operand Stack Management: Pop,pop2,dup,dup2,dup_xl,dup2_xl,dup_x2,dup2_x2,swap
Conditional transfer: Ifeq,iflt,ifle,ifne,ifgt,ifge,ifnull,ifnonnull,if_icmpeq,if_icmpene, if_icmplt,if_icmpgt,if_icmple,if_ Icmpge,if_acmpeq,if_acmpne,lcmp,fcmpl Fcmpg,dcmpl,dcmpg
Compound Conditional transfer: Tableswitch,lookupswitch
Unconditional transfer: Goto,goto_w,jsr,jsr_w,ret
How to implement a scheduled object: invokevirtual
Call the method implemented by the interface: Invokeinterface
Call an instance method that requires special handling: invokespecial
Call a static method in a named class: Invokestatic
method returns: Ireturn,lreturn,freturn,dreturn,areturn,return
Exception: Athrow
The implementation of the FINALLY keyword uses: jsr,jsr_w,ret

Stack and local variable operation instructions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.