48.

prev next contents
astore

store object reference in local variable

Jasmin Syntax
     astore <varnum> or     wide     astore <varnum> 
In the first form, <varnum> is an unsigned integer in the range 0 to 0xFF. In the second (wide) form, <varnum> is an unsigned integer in the range 0 to 0xFFFF.

Stack

Before

After
objectref
...
...

Description

Pops objectref (a reference to an object or array) off the stack and stores it in local variable <varnum>. The astore instruction takes a single parameter, <varnum>, an unsigned integer which indicates which local variable is used. <varnum> must be a valid local variable number in the current frame.

Example

 aload 1    ; Push object reference in local variable 1 onto stack astore 3 ; and store it in local variable 3 
Bytecode

For local variable numbers in the range 0-255, use:

Type

Description
u1
astore opcode = 0x3A (58)
u1
<varnum>
There is also a wide format for this instruction, which supports access to all local variables from 0 to 65535:

Type

Description
u1
wide opcode = 0xC4 (196)
u1
astore opcode = 0x3A (58)
u2
<varnum>
See Also

lstore, istore, dstore, fstore, wide

Notes

astore can also be used to store a returnAddress in a local variable. See the jsr instruction for more details.


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