Store double
into local variable
Bytecode
For local variables in the range 0-255, use:
Type | Description |
u1 | dstore opcode = 0x39 (57) |
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 | dstore opcode = 0x39 (57) |
u2 | <varnum> |
Stack ..., value.word1, value.word2 => ...
Description
dstore pops a two-word double-precision float off the operand stack and stores it
in a local variable. It takes a single parameter, <varnum>, an unsigned integer
indicating which local variable to use.
Since double-precision floats are 64-bits wide, and each local variable can only hold up to 32 bits, Java uses two consecutive local variables, <varnum> and <varnum> + 1 to store a double. So dstore <varnum> actually modifies the values of both <varnum> (which is set to double-word1) and <varnum> + 1 (which is set to double-word2).
Both <varnum> and <varnum> + 1 must be valid local variable numbers in the current frame.
The <varnum> is an unsigned byte or short. Both <varnum> and <varnum>
+ 1 must be valid indices into the of the current frame. The value on the top
of the operand stack must be of type double
. It is popped from the operand
stack, and the local variables at <varnum> and <varnum> + 1 are set to value.
ldc2_w 10.0 ; push the double 10.0 onto the stack dstore 3 ; pop 10.0 off of the stack and store it in local variables 3 and 4
Notes
The dstore opcode can be used in conjunction with the wide
instruction to access a local variable using a two-byte unsigned index.