14.

prev next contents
iconst_<n>

push the integer constant 0, 1, 2, 3, 4 or 5

Jasmin Syntax
     iconst_0 or     iconst_1 or     iconst_2 or     iconst_3 or     iconst_4 or     iconst_5 
Stack

Before

After
...
<n>

...
Description

iconst_<n> represents the series of opcodes iconst_0, iconst_1, iconst_2, iconst_3, iconst_4 and iconst_5. These are used to push the constant ints 0 through 5 onto the stack. For example, to push the int zero onto the stack, use:

 iconst_0 ; push 0 onto the stack. 
Note that you could also use:
 bipush 0 ; push 0 onto the stack 
or
 sipush 0 ; push 0 onto the stack 
or
 ldc 0 ; push 0 onto the stack 
although these instructions are typically less efficient than the equivalent iconst_<n> and also take up more bytes in the class file.

Example

 iconst_0  ; push 0 onto the stack iconst_1  ; push 1 onto the stack iconst_2  ; push 2 onto the stack iconst_3  ; push 3 onto the stack iconst_4  ; push 4 onto the stack iconst_5  ; push 5 onto the stack 
Bytecode

Type

Description
u1
iconst_0 opcode = 0x03 (3)
u1
iconst_1 opcode = 0x04 (4)
u1
iconst_2 opcode = 0x05 (5)
u1
iconst_3 opcode = 0x06 (6)
u1
iconst_4 opcode = 0x07 (7)
u1
iconst_5 opcode = 0x08 (8)
See Also

bipush, sipush, ldc, ldc_w, ldc2_w, aconst_null, iconst_m1, lconst_<l>, fconst_<f>, dconst_<d>


prev next contents
Java Virtual Machine, by Jon Meyer and Troy Downing, O'Reilly Associates


Java Virtual Machine
Java Virtual Machine (Java Series)
ISBN: 1565921941
EAN: 2147483647
Year: 1996
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net