University of Virginia, Department of Computer Science
CS201J: Engineering Software, Fall 2002

Notes: Tuesday 12 November 2002
Schedule

Selected JavaVM Instructions
OpcodeMnemonicDescription
0nopDoes nothing
1aconst_nullPush null on the stack
3iconst_0Push int 0 on the stack
4iconst_1Push int 1 on the stack
8iconst_5Push int 5 on the stack
9lconst_0Push long 0 on the stack
.........
21iload varnumPush the int value in local variable varnum on the stack
22lload varnumPush the long value in local variable varnum on the stack
23fload varnumPush the float value in local variable varnum on the stack
24dload varnumPush the double value in local variable varnum on the stack
25aload varnumPush the object reference in local variable varnum on the stack
26iload_0Push the int value in local variable 0 on the stack
27iload_1Push the int value in local variable 1 on the stack
.........
45aload_3Push the object reference in local variable 3 on the stack
.........
54istore varnumStore the int value at the top of the stack in local variable varnum and pop it from stack
58astore varnumStore the object reference at the top of the stack in local variable varnum and pop it from stack
.........
45aload_3Push the object reference in local variable 3 on the stack
.........
87popPops the top (single word) off the stack
88pop2Pops the top two words off the stack
89dupPops the top of the stack, and pushes that value twice
.........
96iaddPops two ints off the stack, and pushes their sum
97laddPops two longs off the stack, and pushes their sum
104imulPops two ints off the stack, and pushes their product
116inegPops an int off the stack, and pushes its negation
153ifeq labelPops an int off the stack, if it is zero, jump to label
154ifne labelPops an int off the stack, if it is not zero, jump to label
165if_acmpeq labelPops two object references off the stack, if they are equal (same object), jump to label
167goto labelCauses execution to jump to label
172ireturnPops 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.
180getfield fieldPops an object reference from the stack, and pushes the value of the specified field of that object on the stack
181putfield fieldPops a value and an object reference from the stack, and store the value in the specified field of that object
182invokevirtual methodPops 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
183invokespecial methodPops 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.)
184invokestatic methodInvokes the specified static method; pops the parameters from the stack, and stores them in local variables
187new classPushes an object reference to a new object of type class
188newarray typePops an integer off the stack, and pushes a reference to a new array of the specified type and the size of the popped integer
.........
201jsr_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.

Method int max(int, int)
   0 iload_1
   1 iload_2
   2 if_icmple 7
   5 iload_1
   6 ireturn
   7 iload_2
   8 ireturn

CS201J University of Virginia
Department of Computer Science
CS 201J: Engineering Software
Sponsored by the
National Science Foundation
cs201j-staff@cs.virginia.edu