Java Assembly Language

There is currently no standard syntax for representing Java bytecodes in human-readable form. Sun's javap utility provides one representation, but its output is complicated by code offsets and constant pool index numbers. Thus, a simpler syntax of coding in Java bytecodes was created.

Note: This is documentation on the syntax only. To understand what the operands mean and their usage in programming, look at the Java Virtual Machine Specification. Most of the documentation is beta, meaning some of it is out-of-date. Look for the book by Tim Lindholm and Frank Yellin (to be available sometime this summer by Addison-Wesley) for the latest documentation. Excerpts are available at the above link.

The Class File Format

Each Java Assembly file (usually suffixed by .jasm) should have the following format:

[abstract] [final] [public] [interface] class classname 
[extends superclassname]
[implements interfacename [interfacename [...] ] ]
  [sourcefile sourcefilename]

Field Declarations

The declaration of the class's fields should have the following format:

field [access_specifier] [static] [final] [transient] [volatile] type fieldname [= constantvalue]

Method Declarations

The declaration of the class's methods should have the following format:

method [access_specifier] [static] [abstract] [final] [native] [synchronized] returntype methodname ( [arg1 [, arg2 [, ...] ] ] )
[throws exceptionname [exceptionname [...] ] ]
max_stack value1
[max_locals value2]

Access Specifier

An access specifer (used in field declarations and method declarations) is one of the following:

private protected


Code is one or more lines in one of the following formats:

[label] operation
[label] vartype localvarname


An operation is in one of the following formats:


constant_arg_operand constantval

field_ref_operand fieldtype fieldname

method_ref_operand returntype methodname ( [arg1 [,arg2 [...]]] )

class_ref_operand classname

label_operand labelname

local_var_operand localvararg

anewarray anewarrayname

iinc localvararg incrementvalue

default defaultlabel
  value1 : gotolabel1 
  value2 : gotolabel2

multianewarray multianewarraytype dimensions

newarray newarraytype

tableswitch beginval to endval
default defaultlabel

Exception Table

An exception table has the following format:

  startpc1 endpc1 handlerpc1 catchtype1
  startpc2 endpc2 handlerpc2 catchtype2

Line Number Table

A line number table has the following format:

  startpc1 linenumber1
  startpc2 linenumber2

Local Variable Table

An local variable table has the following format:

  startpc1 endpc1 type1 localvar1 slotnum1
  startpc2 endpc2 type2 localvar2 slotnum2

Class Name

A class name has the following format:


Field Name

A field name has the following format:


Method Name

A method name has the following format:



Constants are defined much like in Java:


A type has the following format:


No Arg Operand

The following are no arg operands:

aaload aastore aconst_null aload_0 aload_1 aload_2 aload_3 areturn arraylength astore_0 astore_1 astore_2 astore_3 athrow baload bastore caload castore d2f d2i d2l dadd daload dastore dcmpg dcmpl dconst_0 dconst_1 ddiv dload_0 dload_1 dload_2 dload_3 dmul dneg drem dreturn dstore_0 dstore_1 dstore_2 dstore_3 dsub dup dup_x1 dup_x2 dup2 dup2_x1 dup2_x2 f2d f2i f2l fadd faload fastore fcmpg fcmpl fconst_0 fconst_1 fdiv fload_0 fload_1 fload_2 fload_3 fmul fneg frem freturn fstore_0 fstore_1 fstore_2 fstore_3 fsub i2b i2c i2d i2f i2l i2s iadd iaload iand iastore iconst_0 iconst_1 iconst_2 iconst_3 iconst_4 iconst_5 iconst_m1 idiv iload_0 iload_1 iload_2 iload_3 imul ineg ior irem ireturn ishl ishr istore_0 istore_1 istore_2 istore_3 isub iushr ixor l2d l2f l2i ladd laload land lastore lcmp lconst_0 lconst_1 ldiv lload_0 lload_1 lload_2 lload_3 lmul lneg lor lrem lreturn lshl lshr lstore_0 lstore_1 lstore_2 lstore_3 lsub lushr lxor monitorenter monitorexit nop pop pop2 return saload sastore swap wide

Constant Arg Operand

The following are constant arg operands:

bipush ldc ldc_w ldc2_w sipush

Field Ref Operand

The following are field ref operands:

getfield getstatic putfield putstatic

Method Ref Operand

The following are method ref operands:

invokeinterface invokestatic invokenonvirtual invokevirtual

Class Ref Operand

The following are class ref operands:

checkcast instanceof new

Label Operand

The following are label operands:

goto goto_w if_acmpeq if_acmpne if_icmpeq if_icmpne if_icmplt if_icmpge if_icmpgt if_icmple ifeq ifne iflt ifge ifgt ifle ifnonnull ifnull jsr jsr_w

Local Var Operand

The following are local var operands:

iload fload aload lload dload istore fstore astore lstore dstore ret load store

General Notes