Format | Assembly Format | Description |
---|---|---|
81 <T> | stobj typeTok |
Store a value of type typeTok at an address. |
…, dest, src → …,
The stobj
instruction copies the value src to the address dest. If typeTok is not a generic parameter and either a reference type or a built-in value class, then the stind
instruction provides a shorthand for the stobj
instruction.
Storing values 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 typeTok. (See §III.1.1.1, Numeric data types.)
The operation of the stobj
instruction can be altered by an immediately preceding volatile.
or unaligned.
prefix instruction.
System.NullReferenceException
can be thrown if an invalid address is detected.
System.TypeLoadException
is thrown if typeTok cannot be found. This is typically detected when CIL is converted to native code rather than at runtime.
Correct CIL ensures that dest is a pointer to T
and the type of src is verifier-assignable-to T
.
typeTok shall be a valid typedef
, typeref
, or typespec
metadata token.
[Note: Unlike the stind
instruction a stobj
instruction can be used with a generic parameter type. end note]
Let the tracked type of the value on top of the stack be some type srcType. The value shall be initialized (when srcType is a reference type). The tracked type of the destination address dest on the preceding stack slot shall be a managed pointer (of type destType&) to some type destType. Finally, srcType shall be verifier-assignable-to typeTok.