OpCodes.Add 字段

定义

将两个值相加并将结果推送到计算堆栈上。Adds two values and pushes the result onto the evaluation stack.

public: static initonly System::Reflection::Emit::OpCode Add;
public static readonly System.Reflection.Emit.OpCode Add;
 staticval mutable Add : System.Reflection.Emit.OpCode
Public Shared ReadOnly Add 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
5858 addadd 将两个数值相加,并返回一个新的数值。Adds two numeric values, returning a new numeric value.

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

  1. value1 推送到堆栈上。value1 is pushed onto the stack.

  2. value2 推送到堆栈上。value2 is pushed onto the stack.

  3. value2 和 @no__t 从堆栈中弹出;value1 添加到 @no__t。value2 and value1 are popped from the stack; value1 is added to value2.

  4. 将结果推送到堆栈上。The result is pushed onto the stack.

未检测到用于整数运算的溢出(有关正确的溢出处理,请参阅 Add_Ovf)。Overflow is not detected for integer operations (for proper overflow handling, see Add_Ovf).

整数加法换行,而不是尽量充满。Integer addition wraps, rather than saturates. 例如,假设8位整数,其中 value1 设置为255,value2 设置为1,则已包装的结果为0而不是256。For example, assuming 8-bit integers where value1 is set to 255 and value2 is set to 1, the wrapped result is 0 rather than 256.

浮点溢出返回 +infPositiveInfinity)或 -infNegativeInfinity)。Floating-point overflow returns +inf (PositiveInfinity) or -inf (NegativeInfinity).

下表列出了可接受的操作数类型及其对应的结果数据类型。The acceptable operand types and their corresponding result data type are listed in the table below. 如果没有特定类型组合的条目(例如 int32float; int32 和 @no__t 3),则它是无效的 Microsoft 中间语言(MSIL),并生成错误。If there is no entry for a particular type combination (for example, int32 and float; int32 and int64), it is an invalid Microsoft Intermediate Language (MSIL) and generates an error.

操作数operand value1 类型value1 type value2 类型value2 type 结果类型result type
addadd int32 int32 int32
添加add int32 native int native int
添加add int32 & &
添加add int32 * *
添加add int64 int64 int64
添加add native int int32 native int
添加add native int native int native int
添加add native int & &
添加add native int * *
添加add F F F
添加add & int32 &
添加add & native int &
添加add * int32 *
addadd * native int *

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

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

适用于