Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 2.7 KB

iii.3.62-stind-type.md

File metadata and controls

38 lines (24 loc) · 2.7 KB

III.3.62 stind.<type> – store value indirect from stack

Format Assembly Format Description
52 stind.i1 Store value of type int8 into memory at address
53 stind.i2 Store value of type int16 into memory at address
54 stind.i4 Store value of type int32 into memory at address
55 stind.i8 Store value of type int64 into memory at address
56 stind.r4 Store value of type float32 into memory at address
57 stind.r8 Store value of type float64 into memory at address
DF stind.i Store value of type native int into memory at address
51 stind.ref Store value of type object ref (type O) into memory at address

Stack Transition:

…, addr, val → …

Description:

The stind instruction stores value val at address addr (an unmanaged pointer, type native int, or managed pointer, type &). The address specified by addr shall be aligned to the natural size of val or a NullReferenceException can occur (but see the unaligned. prefix instruction). The results of all CIL instructions that return addresses (e.g., ldloca and ldarga) are safely aligned. For data types larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms.

Storing into locations smaller than 4 bytes truncates the value as it moves from the stack to memory. Floating-point values are rounded from their native size (type F) to the size associated with the instruction. (See §III.1.1.1, Numeric data types.)

The stind.ref instruction is a shortcut for a stobj instruction that specifies the type pointed at by addr, all of the other stind instructions are shortcuts for a stobj instruction that specifies the corresponding built-in value class.

Type-safe operation requires that the stind instruction be used in a manner consistent with the type of the pointer. The operation of the stind instruction can be altered by an immediately preceding volatile. or unaligned. prefix instruction.

Exceptions:

System.NullReferenceException is thrown if addr is not naturally aligned for the argument type implied by the instruction suffix.

Correctness:

Correct CIL ensures that addr is a pointer to T and the type of val is verifier-assignable-to T. For stind.ref the type pointer at by addr cannot be a generic parameter. [Note: A stobj instruction can be used with generic parameter types. end note]

Verifiability:

For verifiable code, addr shall be a managed pointer, T&, and the type of val shall be verifier-assignable-to T.