Contents Prev Next Up


3.2 Pushing Constants onto the Stack

bipush

Push one-byte signed integer
 
bipush = 16
byte1

Stack: ... => ..., value

byte1 is interpreted as a signed 8-bit value. This value is expanded to an integer and pushed onto the operand stack.

sipush

Push two-byte signed integer
 
sipush = 17
byte1
byte2

Stack: ... => ..., item

byte1 and byte2 are assembled into a signed 16-bit value. This value is expanded to an integer and pushed onto the operand stack.

ldc1

Push item from constant pool
 
ldc1 = 18
indexbyte1

Stack: ... => ..., item

indexbyte1 is used as an unsigned 8-bit index into the constant pool of the current class. The item at that index is resolved and pushed onto the stack. If a String is being pushed and there isn't enough memory to allocate space for it then an OutOfMemoryError is thrown.

Note: A String push results in a reference to an object; what other constants do, and explain this somewhere here.

ldc2

Push item from constant pool
 
ldc2 = 19
indexbyte1
indexbyte2

Stack: ... => ..., item

indexbyte1 and indexbyte2 are used to construct an unsigned 16-bit index into the constant pool of the current class. The item at that index is resolved and pushed onto the stack. If a String is being pushed and there isn't enough memory to allocate space for it then an OutOfMemoryError is thrown.

Note: A String push results in a reference to an object; what other constants do, and explain this somewhere here.

ldc2w

Push long or double from constant pool
 
ldc2w = 20
indexbyte1
indexbyte2

Stack: ... => ..., constant-word1, constant-word2

indexbyte1 and indexbyte2 are used to construct an unsigned 16-bit index into the constant pool of the current class. The two-word constant at that index is resolved and pushed onto the stack.

aconst_null

Push null object
 
aconst_null = 1
reference

Stack: ... => ..., null

Push the null object reference onto the stack.

iconst_m1

Push integer constant -1
 
iconst_m1 = 2

Stack: ... => ..., -1

Push the integer -1 onto the stack.

iconst_<n>

Push integer constant
 
iconst_<n>

Stack: ... => ..., <n>

Forms: iconst_0 = 3, iconst_1 = 4, iconst_2 = 5, iconst_3 = 6, iconst_4 = 7, iconst_5 = 8

Push the integer <n> onto the stack.

lconst_<l>

Push long integer constant
 
lconst_<l>

Stack: ... => ..., <l>-word1, <l>-word2

Forms: lconst_0 = 9, lconst_1 = 10

Push the long integer <l> onto the stack.

fconst_<f>

Push single float
 
fconst_<f>

Stack: ... => ..., <f>

Forms: fconst_0 = 11, fconst_1 = 12, fconst_2 = 13

Push the single-precision floating point number <f> onto the stack.

dconst_<d>

Push double float
 
dconst_<d>

Stack: ... => ..., <d>-word1, <d>-word2

Forms: dconst_0 = 14, dconst_1 = 15

Push the double-precision floating point number <d> onto the stack.


Contents Prev Next Up