The Artima Developer Community
Sponsored Link

Bytecode Basics
A First Look at the Bytecodes of the Java Virtual Machine
by Bill Venners
First Published in JavaWorld, September 1996

<<  Page 5 of 7  >>

Advertisement

Popping to local variables
For each opcode that pushes a local variable onto the stack there exists a corresponding opcode that pops the top of the stack back into the local variable. The names of these opcodes can be formed by replacing "load" in the names of the push opcodes with "store". The opcodes that pop ints and floats from the top of the operand stack to a local variable are listed in the following table. Each of these opcodes moves one 32-bit value from the top of the stack to a local variable.

Opcode Operand(s) Description
istore vindex pops int to local variable position vindex
istore_0 (none) pops int to local variable position zero
istore_1 (none) pops int to local variable position one
istore_2 (none) pops int to local variable position two
istore_3 (none) pops int to local variable position three
fstore vindex pops float to local variable position vindex
fstore_0 (none) pops float to local variable position zero
fstore_1 (none) pops float to local variable position one
fstore_2 (none) pops float to local variable position two
fstore_3 (none) pops float to local variable position three

The next table shows the instructions that pop values of type long and double into a local variable. These instructions move a 64-bit value from the top of the operand stack to a local variable.

Opcode Operand(s) Description
lstore vindex pops long to local variable positions vindex and (vindex + 1)
lstore_0 (none) pops long to local variable positions zero and one
lstore_1 (none) pops long to local variable positions one and two
lstore_2 (none) pops long to local variable positions two and three
lstore_3 (none) pops long to local variable positions three and four
dstore vindex pops double to local variable positions vindex and (vindex + 1)
dstore_0 (none) pops double to local variable positions zero and one
dstore_1 (none) pops double to local variable positions one and two
dstore_2 (none) pops double to local variable positions two and three
dstore_3 (none) pops double to local variable positions three and four

The final group of opcodes that pops to local variables are shown in the following table. These opcodes pop a 32-bit object reference from the top of the operand stack to a local variable.

Opcode Operand(s) Description
astore vindex pops object reference to local variable position vindex
astore_0 (none) pops object reference to local variable position zero
astore_1 (none) pops object reference to local variable position one
astore_2 (none) pops object reference to local variable position two
astore_3 (none) pops object reference to local variable position three

<<  Page 5 of 7  >>


Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2017 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us