Contents Prev Next Up

## The Virtual Machine Instruction Set

# Pushing Constants onto the Stack

bipush
sipush
ldc1
ldc2
ldc2w
aconst_null
iconst_m1
iconst_<n>
lconst_<l>
fconst_<f>
dconst_<d>

### bipush

Push one-byte signed integer

    ... => ..., 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

    ... => ..., 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

    ... => ..., 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.

### ldc2

Push item from constant pool

    ... => ..., 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.

### ldc2w

Push long or double from constant pool

    ... => ..., 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

    ... => ..., null

Push the null object onto the stack.

### iconst_m1

Push integer constant -1

    ... => ..., -1

Push the integer -1 onto the stack.

### iconst_<n>

Push integer constant
<n>

    ... => ..., <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

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

Forms: lconst_0 = 9, lconst_1 = 10

Push the long integer <l> onto the stack.

### fconst_<f>

Push single float

    ... => ..., <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

    ... => ..., <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

Generated with CERN WebMaker