# # Oolong reference # # Oolong is an assembly language which maps to Java VM opcodes. # # Instruction names are usually preceded by one of several letters: # # a reference (stored in one slot) or array # b byte (8-bit) or boolean (1-bit) (stored in an int) # c char (Unicode char, stored in an int) # d double (64-bit floating point number, stored in two 32-bit slots) # f float (32-bit floating point number) # i int (32-bit) # l long (64-bit, stored in two 32-bit slots) # s short (stored in an int) # # Descriptions use the following letters: # # a The top slot of the stack. May be an int, float or reference. # b The second stack slot. May be an int, float or reference. # c The third stack slot. May be an int, float or reference. # d The fourth stack slot. May be an int, float or reference. # ab The long or double on top of the stack, made up of slots a and b. # cd The long or double on top of the stack, made up of slots c and d. # # Instructions mostly take no arguments. In these cases the information # is on the stack, or in local variables implied by the instruction name. # # Some instructions take arguments. If the argument is a type: # # Z boolean 4 # C char 5 # F float 6 # D double 7 # B byte 8 # S short 9 # I int 10 # J long 11 # # If the argument is a desc, it can be any of the following concatenated: # # type a type letter (see above) # [desc an array of things # Lclass; a complete class name (note the letter L and the semicolon) # (desc)V a method which returns void # (desc)desc a method which accepts parameters and returns one parameter # # For instance: # # invokevirtual java/io/PrintStream/println (Ljava/lang/String;)V # getstatic java/lang/Math/PI D # invokeinterface MyInterface/mymethod (JJ[Ljava/lang/String;)D 6 # multinewarray [[I 2 # # Hex Name Arguments Description 00 nop do nothing # Loading constants 01 aconst_null push null reference 02 iconst_m1 push -1 (int) 03 iconst_0 push 0 (int) 04 iconst_1 push 1 (int) 05 iconst_2 push 2 (int) 06 iconst_3 push 3 (int) 07 iconst_4 push 4 (int) 08 iconst_5 push 5 (int) 09 lconst_0 push 0 (long) 0A lconst_1 push 1 (long) 0B fconst_0 push 0 (float) 0C fconst_1 push 1 (float) 0D fconst_2 push 2 (float) 0E dconst_0 push 0 (double) 0F dconst_1 push 1 (double) 10 bipush n push int (-128...127) 11 sipush n push short int (-32,768...32767) 12 ldc x push x (a constant int, float or String in first 256 constants in pool) 13 ldc_w x push x (a constant int, float or String) 14 ldc2_w x push x (a constant double or long) # Loading variable 15 iload n push local int variable n 16 lload n push local long variable n 17 fload n push local float variable n 18 dload n push local double variable n 19 aload n push local reference variable n 1A iload_0 push local int variable 0 1B iload_1 push local int variable 1 1C iload_2 push local int variable 2 1D iload_3 push local int variable 3 1E lload_0 push local long variable 0 1F lload_1 push local long variable 1 20 lload_2 push local long variable 2 21 lload_3 push local long variable 3 22 fload_0 push local float variable 0 23 fload_1 push local float variable 1 24 fload_2 push local float variable 2 25 fload_3 push local float variable 3 26 dload_0 push local double variable 0 27 dload_1 push local double variable 1 28 dload_2 push local double variable 2 29 dload_3 push local double variable 3 2A aload_0 push local reference variable 0 2B aload_1 push local reference variable 1 2C aload_2 push local reference variable 2 2D aload_3 push local reference variable 3 2E iaload push int array element a from array b 2F laload push long array element a from array b 30 faload push float array element a from array b 31 daload push double array element a from array b 32 aaload push reference array element a from array b 33 baload push byte array element a from array b 34 caload push char array element a from array b 35 saload push short int array element a from array b # Storing variables 36 istore n store a in local int variable n 37 lstore n store ab in local long variable n 38 fstore n store a in local float variable n 39 dstore n store ab in local double variable n 3A astore n store a in local reference variable n 3B istore_0 store a in local int variable 0 3C istore_1 store a in local int variable 1 3D istore_2 store a in local int variable 2 3E istore_3 store a in local int variable 3 3F lstore_0 store ab in local long variable 0 40 lstore_1 store ab in local long variable 1 41 lstore_2 store ab in local long variable 2 42 lstore_3 store ab in local long variable 3 43 fstore_0 store a in local float variable 0 44 fstore_1 store a in local float variable 1 45 fstore_2 store a in local float variable 2 46 fstore_3 store a in local float variable 3 47 dstore_0 store ab in local double variable 0 48 dstore_1 store ab in local double variable 1 49 dstore_2 store ab in local double variable 2 4A dstore_3 store ab in local double variable 3 4B astore_0 store a in local reference variable 0 4C astore_1 store a in local reference variable 1 4D astore_2 store a in local reference variable 2 4E astore_3 store a in local reference variable 3 4F iastore store int a in array element b of array c 50 lastore store long ab in array element c of array d 51 fastore store float a in array element b of array c 52 dastore store double ab in array element c of array d 53 aastore store reference a in array element b of array c 54 bastore store byte a in array element b of array c 55 castore store char a in array element b of array c 56 sastore store short int a in array element b of array c # Stack manipulation 57 pop remove a 58 pop2 remove ab 59 dup duplicate a 5A dup_x1 duplicate a, insert under b 5B dup_x2 duplicate a. insert under c 5C dup2 duplicate ab 5D dup2_x1 duplicate ab, insert under c 5E dup2_x2 duplicate ab, insert under d 5F swap swap a and b # Arithmetic 60 iadd add int (a+b) 61 ladd add long (ab+cd) 62 fadd add float (a+b) 63 dadd add double (ab+cd) 64 isub subtract int (a-b) 65 lsub subtract long (ab-cd) 66 fsub subtract float (a-b) 67 dsub subtract double (ab-cd) 68 imul multiply int (a*b) 69 lmul multiply long (ab*cd) 6A fmul multiply float (a*b) 6B dmul multply double (ab*cd) 6C idiv divide int (a/b) 6D ldiv divide long (ab/cd) 6E fdiv divide float (a/b) 6F ddiv divide double (ab/cd) 70 irem remainder int (a%b) 71 lrem remainder long (ab%cd) 72 frem remainder float (a%b) 73 drem remainder double (ab%cd) 74 ineg negate int (-a) 75 lneg negate long (-ab) 76 fneg negate float (-a) 77 dneg negate double (-ab) 78 ishl shift int left (a << b) 79 lshl shift long left (ab << c) 7A ishr shift int right (a >> b) 7B lshr shift long right (ab >> c) 7C iushr unsigned shift int right (a >>> b) 7D lushr unsigned shift long right (ab >>> c) 7E iand bitwise int and (a & b) 7F land bitwise long and (ab & cd) 80 ior bitwise int or (a | b) 81 lor bitwise long or (ab | cd) 82 ixor bitwise int xor (a ^ b) 83 lxor bitwise long xor (ab ^ cd) 84 iinc n increment increment local variable n # Conversion 85 i2l convert int a to long 86 i2f convert int a to float 87 i2d convert int a to double 88 l2i convert long ab to int 89 l2f convert long ab to float 8A l2d convert long ab to double 8B f2i convert float a to int 8C f2l convert float a to long 8D f2d convert float a to double 8E d2i convert double ab to int 8F d2l convert double ab to long 90 d2f convert double ab to float 91 i2b convert int a to byte 92 i2c convert int a to char 93 i2s convert int a to short int # Comparison 94 lcmp 95 fcmpl compare float with long 96 fcmpg compare float 97 dcmpl compare double with long 98 dcmpg compare double # Control 99 ifeq label branch if int a == 0 9A ifne label branch if int a != 0 9B iflt label branch if int a < 0 9C ifge label branch if int a >= 0 9D ifgt label branch if int a > 0 9E ifle label branch if int a <= 0 9F if_icmpeq label branch if int a == b A0 if_icmpne label branch if int a != b A1 if_icmplt label branch if int a < b A2 if_icmpge label branch if int a >= b A3 if_icmpgt label branch if int a > b A4 if_icmple label branch if int a <= b A5 if_acmpeq label branch if reference a == b A6 if_acmpne label branch if reference a != b A7 goto label branch always to label A8 jsr label branch to label; push return location A9 ret n branch to location in variable n AA tableswitch n label1 ... labelx branch to label1 on n, label2 on n+1, ... else default AB lookupswitch tag1: label1 ... branch to label1 on tag1 ... else default AC ireturn return int from method AD lreturn return long from method AE freturn return float from method AF dreturn return double from method B0 areturn return reference from method B1 return return from method # Access B2 getstatic class/field desc push static field B3 putstatic class/field desc store a in static field B4 getfield class/field desc push object field B5 putfield class/field desc store a in object field B6 invokevirtual class/method desc invoke method virtually B7 invokespecial class/method desc invoke method directly B8 invokestatic class/method desc invoke static method B9 invokeinterface class/method desc n invoke method through interface with n argument words BA - # Objects BB new class create new object of class BC newarray type create array of type, length a BD anewarray class create array of class, length a BE arraylength push length of array BF athrow throw exception a C0 checkcast class throw exception if a is not an instance of class C1 instanceof class push 1 if a is class, 0 otherwise # Synchronization C2 monitorenter gain control of monitor of a C3 monitorexit release monitor of a # Extras C4 wide instruction args do instruction using wider range of values C5 multinewarray class n create multidimensional array with first n dimensions initialized to lengths a, b, c... C6 ifnull label branch if reference a is null C7 ifnonnull label branch if reference a is not null C8 goto_w label branch always to label C9 jsr_w label jump to label # Unused CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF