cs205: engineering software? |
(none) 20 September 2010 |
Opcode | Mnemonic | Description |
---|---|---|
0 | nop | Does nothing |
1 | aconst_null | Push null on the stack |
3 | iconst_0 | Push int 0 on the stack |
4 | iconst_1 | Push int 1 on the stack |
8 | iconst_5 | Push int 5 on the stack |
9 | lconst_0 | Push long 0 on the stack |
... | ... | ... |
21 | iload varnum | Push the int value in local variable varnum on the stack |
22 | lload varnum | Push the long value in local variable varnum on the stack |
23 | fload varnum | Push the float value in local variable varnum on the stack |
24 | dload varnum | Push the double value in local variable varnum on the stack |
25 | aload varnum | Push the object reference in local variable varnum on the stack |
26 | iload_0 | Push the int value in local variable 0 on the stack |
27 | iload_1 | Push the int value in local variable 1 on the stack | ... | ... | ... |
45 | aload_3 | Push the object reference in local variable 3 on the stack |
... | ... | ... |
54 | istore varnum | Store the int value at the top of the stack in local variable varnum and pop it from stack |
58 | astore varnum | Store the object reference at the top of the stack in local variable varnum and pop it from stack |
... | ... | ... |
45 | aload_3 | Push the object reference in local variable 3 on the stack | ... | ... | ... |
87 | pop | Pops the top (single word) off the stack |
88 | pop2 | Pops the top two words off the stack |
89 | dup | Pops the top of the stack, and pushes that value twice |
... | ... | ... |
96 | iadd | Pops two ints off the stack, and pushes their sum |
97 | ladd | Pops two longs off the stack, and pushes their sum |
104 | imul | Pops two ints off the stack, and pushes their product |
116 | ineg | Pops an int off the stack, and pushes its negation |
153 | ifeq label | Pops an int off the stack, if it is zero, jump to label |
154 | ifne label | Pops an int off the stack, if it is not zero, jump to label |
165 | if_acmpeq label | Pops two object references off the stack, if they are equal (same object), jump to label |
167 | goto label | Causes execution to jump to label |
172 | ireturn | Pops an int off the stack, and pushes it onto the caller's stack. Discards all other items on this method's stack. Causes execution to contion at the call site. |
180 | getfield field | Pops an object reference from the stack, and pushes the value of the specified field of that object on the stack |
181 | putfield field | Pops a value and an object reference from the stack, and store the value in the specified field of that object |
182 | invokevirtual method | Pops an object reference from the stack, and invokes the specified method on that object; pops the parameters from the stack, and stores them in local variables |
183 | invokespecial method | Pops an object reference from the stack, and invokes the specified method on that object; pops the parameters from the stack, and stores them in local variables. (Used for constructors, private methods and super invocations.) |
184 | invokestatic method | Invokes the specified static method; pops the parameters from the stack, and stores them in local variables |
187 | new class | Pushes an object reference to a new object of type class |
188 | newarray type | Pops an integer off the stack, and pushes a reference to a new array of the specified type and the size of the popped integer |
... | ... | ... |
201 | jsr_w label | Jump to a subroutine using a wide offset (useful for exception handling) |
For a complete description of all the JavaVM instructions, see The JavaTM Virtual Machine Specification.
To examine the byte codes the compiler produces for a class:
Method void main(java.lang.String[]) 0 iconst_2 1 istore_1 2 iconst_3 3 istore_2 4 iload_1 5 iload_2 6 iadd 7 istore_3 8 getstatic #2 <Field java.io.PrintStream err> 11 new #3 <Class java.lang.StringBuffer> 14 dup 15 invokespecial #4 <Method java.lang.StringBuffer()> 18 ldc #5 <String "c: "> 20 invokevirtual #6 <Method java.lang.StringBuffer append(java.lang.String)> 23 iload_3 24 invokevirtual #7 <Method java.lang.StringBuffer append(int)> 27 invokevirtual #8 <Method java.lang.String toString()> 30 invokevirtual #9 <Method void println(java.lang.String)> 33 return