cs205: engineering software?
(none)
20 September 2010

CS205 Notes 30 (1 November 2006)

Upcoming Schedule

  • Now — project idea description
  • Monday, November 6: Quiz 4
  • Friday, November 10 (beginning of class) — project design document
  • week of November 13 — project design reviews
  • week of November 27 — project progress reports
  • Monday, December 4 (in class) — project presentations/demos
  • Tuesday, December 5 (before 5pm) — project final reports including code and teammate assessments

    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.

    To examine the byte codes the compiler produces for a class:

    1. Start a DOS shell by selecting "Run" from the Start menu and entering "cmd"
    2. cd to the directory containing the class file
    3. java -p classname
    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