Format | Assembly Format | Description |
---|---|---|
71 <\T> | ldobj typeTok |
Copy the value stored at_address src to the stack. |
…, src → …, val
The ldobj
instruction copies a value to the evaluation stack. typeTok is a metadata token (a typedef
, typeref
, or typespec
). src is an unmanaged pointer (native int
), or a managed pointer (&
). If typeTok is not a generic parameter and either a reference type or a built-in value class, then the ldind
instruction provides a shorthand for the ldobj
instruction.
[Rationale: The ldobj
instruction can be used to pass a value type as an argument. end rationale]
If required values are converted to the representation of the intermediate type (§I.8.7) of typeTok when loaded onto the stack (§III.1.1.1).
[Note: That is integer values of less than 4 bytes, a boolean or a character are converted to 4 bytes by sign or zero-extension as appropriate. Floating-point values are converted to F
type. end note]
The operation of the ldobj
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.
typeTok shall be a valid typedef
, typeref
, or typespec
metadata token.
[Note: Unlike the ldind
instruction a ldobj
instruction can be used with a generic parameter type. end note]
The tracked type of the source value on top of the stack shall be a managed pointer to some type srcType, and srcType shall be assignable-to the type typeTok.
Verification tracks the type of the result val as the intermediate type of typeTok.