JVM Instructions
The JVM specification defines nearly 200+ instructions, as shown in the table below:
| op | Syntax | Stack | Description |
|---|---|---|---|
| 0x00 | nop | No change | Do nothing |
| 0x01 | aconst_null | ... → ...,null | Push null reference onto the stack[^1] top |
| 0x02 | iconst_m1 | ... → ...,-1 | Push int constant -1 onto the stack top |
| 0x03 | iconst_0 | .. . → ...,0 | Push int constant 0 onto the stack top |
| 0x04 | iconst_1 | ... → ...,1 | Push int constant 1 onto the stack top |
| 0x05 | iconst_2 | ... → ...,2 | Push int constant 2 onto the stack top |
| 0x06 | iconst_3 | ... → ...,3 | Push int constant 3 onto the stack top |
| 0x07 | iconst_4 | ... → ...,4 | Push int constant 4 onto the stack top |
| 0x08 | iconst_5 | ... → ...,5 | Push int constant 5 onto the stack top |
| 0x09 | lconst_0 | ... → ...,0L | Push long constant 0L onto the stack top |
| 0x0a | lconst_1 | ... → ...,1L | Push long constant 1L onto the stack top |
| 0x0b | fconst_0 | ... → ...,0.0f | Push float constant 0.0f onto the stack top |
| 0x0c | fconst_1 | ... → ...,1.0f | Push float constant 1.0f onto the stack top |
| 0x0d | fconst_2 | ... → ...,2.0f | Push float constant 1.0f onto the stack top |
| 0x0e | dconst_0 | ... → ...,0.0 | Push double constant 0.0 onto the stack top |
| 0x0f | dconst_1 | ... → ...,1.0 | Push double constant 1.0 onto the stack top |
| 0x10 | bipush,AA[^2] | ... → ...,v | Push immediate[^3] value AA onto the stack top |
| 0x11 | sipush,AAAA[^4] | ... → ...,v | Push immediate value AAAA onto the stack top |
| 0x12 | ldc,AA | ... → ...,v | Push constant at index AA in constant pool onto the stack top |
| 0x13 | ldc_w,AAAA | ... → ...,v | Push constant at index AAAA in constant pool onto the stack top |
| 0x14 | ldc2_w,AAAA | ... → ...,v | Push long or double constant at index AAAA in constant pool onto the stack top |
| 0x15 | iload,AA | ... → ...,v | Push int variable at index AA in local variable table onto the stack top |
| 0x16 | lload,AA | ... → ...,v | Push long variable at index AA in local variable table onto the stack top |
| 0x17 | fload,AA | ... → ...,v | Push float variable at index AA in local variable table onto the stack top |
| 0x18 | dload,AA | ... → ...,v | Push double variable at index AA in local variable table onto the stack top |
| 0x19 | aload,AA | ... → ...,v | Push aref at index AA in local variable table onto the stack top |
| 0x1a | iload_0 | ... → ...,0 | Push int variable at index 0 in local variable table onto the stack top |
| 0x1b | iload_1 | ... → ...,1 | Push int variable at index 1 in local variable table onto the stack top |
| 0x1c | iload_2 | ... → ...,2 | Push int variable at index 2 in local variable table onto the stack top |
| 0x1d | iload_3 | ... → ...,3 | Push int variable at index 3 in local variable table onto the stack top |
| 0x1e | lload_0 | ... → ...,0L | Push long variable at index 0 in local variable table onto the stack top |
| 0x1f | lload_1 | ... → ...,1L | Push long variable at index 1 in local variable table onto the stack top |
| 0x20 | lload_2 | ... → ...,2L | Push long variable at index 2 in local variable table onto the stack top |
| 0x21 | lload_3 | ... → ...,3L | Push long variable at index 3 in local variable table onto the stack top |
| 0x22 | fload_0 | ... → ...,0.0f | Push float variable at index 0 in local variable table onto the stack top |
| 0x23 | fload_1 | ... → ...,1.0f | Push float variable at index 1 in local variable table onto the stack top |
| 0x24 | fload_2 | ... → ...,2.0f | Push float variable at index 2 in local variable table onto the stack top |
| 0x25 | fload_3 | ... → ...,3.0f | Push float variable at index 3 in local variable table onto the stack top |
| 0x26 | dload_0 | ... → ...,0.0 | Push double variable at index 0 in local variable table onto the stack top |
| 0x27 | dload_1 | ... → ...,1.0 | Push double variable at index 1 in local variable table onto the stack top |
| 0x28 | dload_2 | ... → ...,2.0 | Push double variable at index 2 in local variable table onto the stack top |
| 0x29 | dload_3 | ... → ...,3.0 | Push double variable at index 3 in local variable table onto the stack top |
| 0x2a | aload_0 | ... → ...,aref | Push aref at index 0 in local variable table onto the stack top |
| 0x2b | aload_1 | ... → ...,aref | Push aref at index 1 in local variable table onto the stack top |
| 0x2c | aload_2 | ... → ...,aref | Push aref at index 2 in local variable table onto the stack top |
| 0x2d | aload_3 | ... → ...,aref | Push aref at index 3 in local variable table onto the stack top |
| 0x2e | iaload* | ...,aaref,index → ...,v | Push int value at index (int) in array aaref onto the stack top |
| 0x2f | laload | ...,aaref,index → ...,v | Push long value at index (int) in array aaref onto the stack top |
| 0x30 | faload | ...,aaref,index → ...,v | Push float value at index (int) in array aaref onto the stack top |
| 0x31 | daload | ...,aaref,index → ...,v | Push double value at index (int) in array aaref onto the stack top |
| 0x32 | aaload | ...,aaref,index → ...,v | Push reference value at index (int) in array aaref onto the stack top |
| 0x33 | baload | ...,aaref,index → ...,v | Push byte or boolean value at index (int) in array aaref onto the stack top |
| 0x34 | caload | ...,aaref,index → ...,v | Push char value at index (int) in array aaref onto the stack top |
| 0x35 | saload | ...,aaref,index → ...,v | Push short value at index (int) in array aaref onto the stack top |
| 0x36 | istore,AA | ...,v → ..., | Pop int value from stack top and store to local variable at index AA |
| 0x37 | lstore,AA | ...,v → ..., | Pop long value from stack top and store to local variable at index AA |
| 0x38 | fstore,AA | ...,v → ..., | Pop float value from stack top and store to local variable at index AA |
| 0x39 | dstore,AA | ...,v → ..., | Pop double value from stack top and store to local variable at index AA |
| 0x3a | astore,AA | ...,v → ..., | Pop reference value from stack top and store to local variable at index AA |
| 0x3b | istore_0 | ...,v → ..., | Pop int value from stack top and store to local variable at index 0 |
| 0x3c | istore_1 | ...,v → ..., | Pop int value from stack top and store to local variable at index 1 |
| 0x3d | istore_2 | ...,v → ..., | Pop int value from stack top and store to local variable at index 2 |
| 0x3e | istore_3 | ...,v → ..., | Pop int value from stack top and store to local variable at index 3 |
| 0x3f | lstore_0 | ...,v → ..., | Pop long value from stack top and store to local variable at index 0 |
| 0x40 | lstore_1 | ...,v → ..., | Pop long value from stack top and store to local variable at index 1 |
| 0x41 | lstore_2 | ...,v → ..., | Pop long value from stack top and store to local variable at index 2 |
| 0x42 | lstore_3 | ...,v → ..., | Pop long value from stack top and store to local variable at index 3 |
| 0x43 | fstore_0 | ...,v → ..., | Pop float value from stack top and store to local variable at index 0 |
| 0x44 | fstore_1 | ...,v → ..., | Pop float value from stack top and store to local variable at index 1 |
| 0x45 | fstore_2 | ...,v → ..., | Pop float value from stack top and store to local variable at index 2 |
| 0x46 | fstore_3 | ...,v → ..., | Pop float value from stack top and store to local variable at index 3 |
| 0x47 | dstore_0 | ...,v → ..., | Pop double value from stack top and store to local variable at index 0 |
| 0x48 | dstore_1 | ...,v → ..., | Pop double value from stack top and store to local variable at index 1 |
| 0x49 | dstore_2 | ...,v → ..., | Pop double value from stack top and store to local variable at index 2 |
| 0x4a | dstore_3 | ...,v → ..., | Pop double value from stack top and store to local variable at index 3 |
| 0x4b | astore_0 | ...,aref → ..., | Pop reference value from stack top and store to local variable at index 0 |
| 0x4c | astore_1 | ...,aref → ..., | Pop reference value from stack top and store to local variable at index 1 |
| 0x4d | astore_2 | ...,aref → ..., | Pop reference value from stack top and store to local variable at index 2 |
| 0x4e | astore_3 | ...,aref → ..., | Pop reference value from stack top and store to local variable at index 3 |
| 0x4f | iastore | ...,aaref,index,v → ..., | Pop aaref, index (int), v (int) from stack top and store v into aaref[index] |
| 0x50 | lastore | ...,aaref,index,v → ..., | Pop aaref, index (int), v (long) from stack top and store v into aaref[index] |
| 0x51 | fastore | ...,aaref,index,v → ..., | Pop aaref, index (int), v (float) from stack top and store v into aaref[index] |
| 0x52 | dastore | ...,aaref,index,v → ..., | Pop aaref, index (int), v (double) from stack top and store v into aaref[index] |
| 0x53 | aastore | ...,aaref,index,v → ..., | Pop aaref, index (int), v (reference) from stack top and store v into aaref[index] |
| 0x54 | bastore | ...,aaref,index,v → ..., | Pop aaref, index (int), v (byte) from stack top and store v into aaref[index] |
| 0x55 | castore | ...,aaref,index,v → ..., | Pop aaref, index (int), v (char) from stack top and store v into aaref[index] |
| 0x56 | sastore | ...,aaref,index,v → ..., | Pop aaref, index (int), v (short) from stack top and store v into aaref[index] |
| 0x57 | pop | ...,v → ..., | Pop the top value from the stack |
| 0x58 | pop2 | ...,v2,v1 → ..., | Pop 1 or 2 values from the stack top |
| 0x59 | dup | ...,v → ...,v,v | Duplicate the top value and push the duplicate onto the stack top |
| 0x5a | dup_x1 | ...,v2,v1 → ...,v1,v2,v1 | Duplicate the top value and insert the duplicate at the 2nd position from the top |
| 0x5b | dup_x2 | ...,v3,v2,v1 → ...,v1,v3,v2,v1 | Duplicate the top value and insert the duplicate at the 2nd or 3rd position from the top |
| 0x5c | dup2 | ...,v2,v1 → ...,v2,v1,v2,v1 | Duplicate the top 1 or 2 values and push the duplicates onto the stack in original order |
| 0x5d | dup2_x1 | ...,v3,v2,v1 → ...,v2,v1,v3,v2,v1 | Duplicate the top 1 or 2 values and insert the duplicates at the 2nd or 3rd position from the top in original order |
| 0x5e | dup2_x2 | ...,v4,v3,v2,v1 → ...,v2,v1,v4,v3,v2,v1 | Duplicate the top 1 or 2 values and insert the duplicates at the 2nd, 3rd, or 4th position from the top in original order |
| 0x5f | swap | ...,v2,v1 → ...,v1,v2 | Swap the top two values on the stack |
| 0x60 | iadd | ...,v1,v2 → ...,result | Add the top two int values and push the result onto the stack top |
| 0x61 | ladd | ...,v1,v2 → ...,result | Add the top two long values and push the result onto the stack top |
| 0x62 | fadd | ...,v1,v2 → ...,result | Add the top two float values and push the result onto the stack top |
| 0x63 | dadd | ...,v1,v2 → ...,result | Add the top two double values and push the result onto the stack top |
| 0x64 | isub | ...,v1,v2 → ...,result | Subtract the top int value from the second top int value and push the result onto the stack top |
| 0x65 | lsub | ...,v1,v2 → ...,result | |
| 0x66 | fsub | ...,v1,v2 → ...,result | |
| 0x67 | dsub | ...,v1,v2 → ...,result | |
| 0x68 | imul | ...,v1,v2 → ...,result | |
| 0x69 | lmul | ...,v1,v2 → ...,result | |
| 0x6a | fmul | ...,v1,v2 → ...,result | |
| 0x6b | dmul | ...,v1,v2 → ...,result | |
| 0x6c | idiv | ...,v1,v2 → ...,result | |
| 0x6d | ldiv | ...,v1,v2 → ...,result | |
| 0x6e | fdiv | ...,v1,v2 → ...,result | |
| 0x6f | ddiv | ...,v1,v2 → ...,result | |
| 0x70 | irem | ...,v1,v2 → ...,result | |
| 0x71 | lrem | ...,v1,v2 → ...,result | |
| 0x72 | frem | ...,v1,v2 → ...,result | |
| 0x73 | drem | ...,v1,v2 → ...,result | |
| 0x74 | ineg | ...,v1,v2 → ...,result | |
| 0x75 | lneg | ...,v1,v2 → ...,result | |
| 0x76 | fneg | ...,v1,v2 → ...,result | |
| 0x77 | dneg | ...,v1,v2 → ...,result | |
| 0x78 | ishl | ...,v1,v2 → ...,result | |
| 0x79 | lshl | ...,v1,v2 → ...,result | |
| 0x7a | ishr | ...,v1,v2 → ...,result | |
| 0x7b | lshr | ...,v1,v2 → ...,result | |
| 0x7c | iushr | ...,v1,v2 → ...,result | |
| 0x7d | lushr | ...,v1,v2 → ...,result | |
| 0x7e | iand | ...,v1,v2 → ...,result | |
| 0x7f | land | ...,v1,v2 → ...,result | |
| 0x80 | ior | ...,v1,v2 → ...,result | |
| 0x81 | lor | ...,v1,v2 → ...,result | |
| 0x82 | ixor | ...,v1,v2 → ...,result | |
| 0x83 | lxor | ...,v1,v2 → ...,result | |
| 0x84 | iinc,AA,+BB[^5] | ...,v → ...,result | |
| 0x85 | i2l | ...,v → ...,result | |
| 0x86 | i2f | ...,v → ...,result | |
| 0x87 | i2d | ...,v → ...,result | |
| 0x88 | l2i | ...,v → ...,result | |
| 0x89 | l2f | ...,v → ...,result | |
| 0x8a | l2d | ...,v → ...,result | |
| 0x8b | f2i | ...,v → ...,result | |
| 0x8c | f2l | ...,v → ...,result | |
| 0x8d | f2d | ...,v → ...,result | |
| 0x8e | d2i | ...,v → ...,result | |
| 0x8f | d2l | ...,v → ...,result | |
| 0x90 | d2f | ...,v → ...,result | |
| 0x91 | i2b | ...,v → ...,result | |
| 0x92 | i2c | ...,v → ...,result | |
| 0x93 | i2s | ...,v → ...,result | |
| 0x94 | lcmp | ...,v1,v2 → ...,result | |
| 0x95 | fcmpl | ...,v1,v2 → ...,result | |
| 0x96 | fcmpg | ...,v1,v2 → ...,result | |
| 0x97 | dcmpl | ...,v1,v2 → ...,result | |
| 0x98 | dcmpg | ...,v1,v2 → ...,result | |
| 0x99 | ifeq,+AAAA | ...,v1,v2 → ...,result | |
| 0x9a | ifne,+AAAA | ...,v1,v2 → ...,result | |
| 0x9b | iflt,+AAAA | ...,v1,v2 → ...,result | |
| 0x9c | ifge,+AAAA | ...,v1,v2 → ...,result | |
| 0x9d | ifgt,+AAAA | ...,v1,v2 → ...,result | |
| 0x9e | ifle,+AAAA | ...,v1,v2 → ...,result | |
| 0x9f | if_icmpeq,+AAAA | ...,v1,v2 → ...,result | |
| 0xa7 | goto,+AAAA | ||
| 0xa0 | if_icmpne,+AAAA | ...,v1,v2 → ...,result | |
| 0xa1 | if_icmplt,+AAAA | ...,v1,v2 → ...,result | |
| 0xa2 | if_icmpge,+AAAA | ...,v1,v2 → ...,result | |
| 0xa3 | if_icmpgt,+AAAA | ...,v1,v2 → ...,result | |
| 0xa4 | if_icmple,+AAAA | ...,v1,v2 → ...,result | |
| 0xa5 | if_acmpeq,+AAAA | ...,v1,v2 → ...,result | |
| 0xa6 | if_acmpne,+AAAA | ...,v1,v2 → ...,result | |
| 0xa8 | jsr,+AAAA | ... → ...,address | |
| 0xa9 | ret,AA | No change | |
| 0xaa | tableswitch [0]{0,3} +AAAAAAAA +BBBBBBBB +CCCCCCCC {+DDDDDDDD..+NNNNNNNN} | ...,index → ... | |
| 0xab | lookupswitch [0]{0,3} +AAAAAAAA +BBBBBBBB +CCCCCCCC {+DDDDDDDD..+NNNNNNNN} | ...,key → ... | |
| 0xac | ireturn | ...,v → [empty] | |
| 0xad | lreturn | ...,v → [empty] | |
| 0xae | freturn | ...,v → [empty] | |
| 0xaf | dreturn | ...,v → [empty] | |
| 0xb0 | areturn | ...,v → [empty] | |
| 0xb1 | return | ...,v → [empty] | |
| 0xb2 | getstatic,AAAA | ... → ...,v | |
| 0xb3 | putstatic,AAAA | ... → ...,v | |
| 0xb4 | getfield,AAAA | ...,aref → ...,v | |
| 0xb5 | putfield,AAAA | ...,aref → ...,v | |
| 0xb6 | invokevirtual,AAAA | ...,aref,[arg1,[arg2...]] → ... | |
| 0xb7 | invokespecial,AAAA | ...,aref,[arg1,[arg2...]] → ... | |
| 0xb8 | invokestatic,AAAA | ...,[arg1,[arg2...]] → ... | |
| 0xb9 | invokeinterface,AAAA,BB,00 | ...,aref,[arg1,[arg2...]] → ... | |
| 0xba | invokedynamic,AAAA,00,00 | ...,[arg1,[arg2...]] → ... | |
| 0xbb | new,AAAA | ... → ...,aref | |
| 0xbc | newarray,AA | ...,count → ...,aaref | |
| 0xbd | anewarray,AAAA | ...,count → ...,aaref | |
| 0xbe | arraylength | ...,aaref → ...,length | |
| 0xbf | athrow | ...,aref → ...,aref | |
| 0xc0 | checkcast,AAAA | ...,aref → ...,aref | |
| 0xc1 | instanceof,AAAA | ...,aref → ...,result | |
| 0xc2 | monitorenter | ...,aref → ... | |
| 0xc3 | monitorexit | ...,aref → ... | |
| 0xc4 | wide,<opcode>,AAAA,[BBBB] | Same as original instruction | |
| 0xc5 | multianewarray,AAAA,BB | ...,count1,[count2,...] → ...,aaref | |
| 0xc6 | ifnull,+AAAA | ...,v → ... | |
| 0xc7 | ifnonnull,+AAAA | ...,v → ... | |
| 0xc8 | goto_w,+AAAAAAAA | No change | |
| 0xc9 | jsr_w,+AAAAAAAA | ... → ...,address | |
| 0xca | breakpoint | Reserved for Java debugger | |
| 0xcb | ... | Reserved | |
| ... | ... | Reserved | |
| 0xfd | ... | Reserved | |
| 0xfe | impdep1 | Reserved for debugger | |
| 0xff | impdep2 | Reserved for debugger |
[^1]: A stack structure used for storing operands. JVM instructions take operands from the stack during execution and push results back to the stack top. The stack is also used to store method parameters (the first parameter of non-static methods is the this reference) and method return results. [^2]: AA represents 1 unsigned byte (unsigned byte) [^3]: Data that is directly encoded in the instruction and used as an operand. For example: bipush 0x10, where 0x10 is directly encoded into the instruction sequence, which is an immediate value. [^4]: AAAA represents 1 unsigned 16-bit integer (unsigned 16-bit int) [^5]: +BB represents 1 signed byte (signed byte)
