OpCodes.Ldind_U1 字段

定义

unsigned int8 类型的值作为 int32 间接加载到计算堆栈上。Loads a value of type unsigned int8 as an int32 onto the evaluation stack indirectly.

public: static initonly System::Reflection::Emit::OpCode Ldind_U1;
public static readonly System.Reflection.Emit.OpCode Ldind_U1;
 staticval mutable Ldind_U1 : System.Reflection.Emit.OpCode
Public Shared ReadOnly Ldind_U1 As OpCode 

字段值

注解

下表列出了指令的十六进制和 Microsoft 中间语言(MSIL)程序集格式以及简短的参考摘要:The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:

格式Format 程序集格式Assembly Format 说明Description
4747 ldindldind.u1 将位于地址 addr 的 @no__t 0 值作为 @no__t 加载到堆栈上。Loads the unsigned int8 value at address addr onto the stack as an int32.

堆栈转换行为顺序如下:The stack transitional behavior, in sequential order, is:

  1. 地址被推送到堆栈上。An address is pushed onto the stack.

  2. 从堆栈中弹出该地址;获取位于地址的值。The address is popped from the stack; the value located at the address is fetched.

  3. 提取的值被推送到堆栈上。The fetched value is pushed onto the stack.

@No__t-0 指令将 @no__t 的值从指定的地址(类型为 @ no__t,&,或 *)间接加载到堆栈上,并将其指定为 int32The ldind.u1 instruction indirectly loads an unsigned int8 value from the specified address (of typenative int, &, or *) onto the stack as an int32.

所有 ldind 指令都是指定相应内置值类的 @no__t 1 指令的快捷方式。All of the ldind instructions are shortcuts for a Ldobj instruction that specifies the corresponding built-in value class.

请注意,在将小于4个字节的整数值加载到计算堆栈上时,将其扩展到 int32 (而不是 native int)。Note that integer values of less than 4 bytes are extended to int32 (not native int) when they are loaded onto the evaluation stack. 将浮点值加载到计算堆栈上时,会将其转换为 @no__t 类型。Floating-point values are converted to F type when loaded onto the evaluation stack.

格式正确的 Microsoft 中间语言(MSIL)确保以与指针类型一致的方式使用 @no__t 的指令。Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.

最初推送到堆栈上的地址必须与计算机上对象的自然大小对齐,否则可能出现 NullReferenceException (请参阅针对预防措施的 @no__t 1 前缀指令)。The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a NullReferenceException can occur (see the Unaligned prefix instruction for preventative measures). 返回地址的所有 MSIL 指令(例如 LdlocaLdarga)的结果将安全对齐。The results of all MSIL instructions that return addresses (for example, Ldloca and Ldarga) are safely aligned. 对于大于1个字节的数据类型,字节排序依赖于目标 CPU。For datatypes 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.

如果检测到无效地址,则可能引发 NullReferenceExceptionNullReferenceException can be thrown if an invalid address is detected.

以下 @no__t 0 方法重载可以使用 @no__t 操作码:The following Emit method overload can use the ldind.u1 opcode:

  • ILGenerator.Emit(OpCode)ILGenerator.Emit(OpCode)

适用于