Format | Assembly Format | Description |
---|---|---|
FE 0E <unsigned int16> | stloc indx |
Pop a value from stack into local variable indx. |
13 <unsigned int8> | stloc.s indx |
Pop a value from stack into local variable indx, short form. |
0A | stloc.0 |
Pop a value from stack into local variable 0. |
0B | stloc.1 |
Pop a value from stack into local variable 1. |
0C | stloc.2 |
Pop a value from stack into local variable 2. |
0D | stloc.3 |
Pop a value from stack into local variable 3. |
…, value → …
The stloc
indx instruction pops the top value off the evaluation stack and moves it into local variable number indx (see Partition I), where local variables are numbered 0 onwards. The type of value shall match the type of the local variable as specified in the current method's locals signature. The stloc.0
, stloc.1
, stloc.2
, and stloc.3
instructions provide an efficient encoding for the first 4 local variables; the stloc.s
instruction provides an efficient encoding for local variables 4–255.
Storing into locals that hold a value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type F
) to the size associated with the argument. (See §III.1.1.1, Numeric data types.)
None.
Correct CIL requires that indx be a valid local index. For the stloc
indx instruction, indx shall lie in the range 0–65534 inclusive (specifically, 65535 is not valid).
[Rationale: The reason for excluding 65535 is pragmatic: likely implementations will use a 2-byte integer to track both a local's index, as well as the total number of locals for a given method. If an index of 65535 had been made valid, it would require a wider integer to track the number of locals in such a method. end rationale]
Verification also checks that the type of value is verifier-assignable-to the type of the local, as specified in the current method’s locals signature.