public class OpCodes
|
Add | Adds two values and pushes the result onto the evaluation stack. |
Add_Ovf | Adds two integers, performs an overflow check, and pushes the result onto the evaluation stack. |
Add_Ovf_Un | Adds two unsigned integer values, performs an overflow check, and pushes the result onto the evaluation stack. |
And | Computes the bitwise AND of two values and pushes the result onto the evalution stack. |
Arglist | Returns an unmanaged pointer to the argument list of the current method. |
Beq | Transfers control to a target instruction if two values are equal. |
Beq_S | Transfers control to a target instruction (short form) if two values are equal. |
Bge | Transfers control to a target instruction if the first value is greater than or equal to the second value. |
Bge_S | Transfers control to a target instruction (short form) if the first value is greater than or equal to the second value. |
Bge_Un | Transfers control to a target instruction if the the first value is greather than the second value, when comparing unsigned integer values or unordered float values. |
Bge_Un_S | Transfers control to a target instruction (short form) if if the the first value is greather than the second value, when comparing unsigned integer values or unordered float values. |
Bgt | Transfers control to a target instruction if the first value is greater than the second value. |
Bgt_S | Transfers control to a target instruction (short form) if the first value is greater than the second value. |
Bgt_Un | Transfers control to a target instruction if the first value is greater than the second value, when comparing unsigned integer values or unordered float values. |
Bgt_Un_S | Transfers control to a target instruction (short form) if the first value is greater than the second value, when comparing unsigned integer values or unordered float values. |
Ble | Transfers control to a target instruction if the first value is less than or equal to the second value. |
Ble_S | Transfers control to a target instruction (short form) if the first value is less than or equal to the second value. |
Ble_Un | Transfers control to a target instruction if the first value is less than or equal to the second value, when comparing unsigned integer values or unordered float values. |
Ble_Un_S | Transfers control to a target instruction (short form) if the first value is less than or equal to the second value, when comparing unsigned integer values or unordered float values. |
Blt | Transfers control to a target instruction if the first value is less than the second value. |
Blt_S | Transfers control to a target instruction (short form) if the first value is less than the second value. |
Blt_Un | Transfers control to a target instruction if the first value is less than the second value, when comparing unsigned integer values or unordered float values. |
Blt_Un_S | Transfers control to a target instruction (short form) if the first value is less than the second value, when comparing unsigned integer values or unordered float values. |
Bne_Un | Transfers control to a target instruction when two unsigned integer values or unordered float values are not equal. |
Bne_Un_S | Transfers control to a target instruction (short form) when two unsigned integer values or unordered float values are not equal. |
Box | Converts a value type to an object reference (type O). |
Br | Unconditionally transfers control to a target instruction. |
Br_S | Unconditionally transfers control to a target instruction (short form). |
Break | Signals the Common Language Infrastructure (CLI) to inform the debugger that a break point has been tripped. |
Brfalse | Transfers control to a target instruction if value is false, a null reference (not set or empty), or zero. |
Brfalse_S | Transfers control to a target instruction if value is false, a null reference, or zero. |
Brtrue | Transfers control to a target instruction if value is true, not null, or non-zero. |
Brtrue_S | Transfers control to a target instruction (short form) if value is true, not null, or non-zero. |
Call | Calls the method indicated by the passed method descriptor. |
Calli | Calls the method indicated on the evaluation stack (as a pointer to an entry point) with arguments described by a calling convention. |
Callvirt | Calls a late-bound method on an object, pushing the return value onto the evaluation stack. |
Castclass | Attempts to cast an object passed by reference to the specified class. |
Ceq | Compares two values. If they are equal, the integer value 1 (int32) is pushed onto the evaluation stack; otherwise 0 (int32) is pushed onto the evaluation stack. |
Cgt | Compares two values. If the first value is greater than the second, the integer value 1 (int32) is pushed onto the evaluation stack; otherwise 0 (int32) is pushed onto the evaluation stack. |
Cgt_Un | Compares two unsigned or unordered values. If the first value is greater than the second, the integer value 1 (int32) is pushed onto the evaluation stack; otherwise 0 (int32) is pushed onto the evaluation stack. |
Ckfinite | Throws ArithmeticException if value is not a finite number. |
Clt | Compares two values. If the first value is less than the second, the integer value 1 (int32) is pushed onto the evaluation stack; otherwise 0 (int32) is pushed onto the evaluation stack. |
Clt_Un | Compares the unsigned or unordered values value1 and value2. If value1 is less than value2, then the integer value 1 (int32) is pushed onto the evaluation stack; otherwise 0 (int32) is pushed onto the evaluation stack. |
Conv_I | Converts the value on top of the evaluation stack to natural int. |
Conv_I1 | Converts the value on top of the evaluation stack to int8, then extends (pads) it to int32. |
Conv_I2 | Converts the value on top of the evaluation stack to int16, then extends (pads) it to int32. |
Conv_I4 | Converts the value on top of the evaluation stack to int32. |
Conv_I8 | Converts the value on top of the evaluation stack to int64. |
Conv_Ovf_I | Converts the signed value on top of the evaluation stack to signed natural int, throwing OverflowException on overflow. |
Conv_Ovf_I_Un | Converts the unsigned value on top of the evaluation stack to signed natural int, throwing OverflowException on overflow. |
Conv_Ovf_I1 | Converts the signed value on top of the evaluation stack to signed int8 and extends it to int32, throwing OverflowException on overflow. |
Conv_Ovf_I1_Un | Converts the unsigned value on top of the evaluation stack to signed int8 and extends it to int32, throwing OverflowException on overflow. |
Conv_Ovf_I2 | Converts the signed value on top of the evaluation stack to signed int16 and extending it to int32, throwing OverflowException on overflow. |
Conv_Ovf_I2_Un | Converts the unsigned value on top of the evaluation stack to signed int16 and extends it to int32, throwing OverflowException on overflow. |
Conv_Ovf_I4 | Converts the signed value on top of the sevaluation tack to signed int32, throwing OverflowException on overflow. |
Conv_Ovf_I4_Un | Converts the unsigned value on top of the evaluation stack to signed int32, throwing OverflowException on overflow. |
Conv_Ovf_I8 | Converts the signed value on top of the evaluation stack to signed int64, throwing OverflowException on overflow. |
Conv_Ovf_I8_Un | Converts the unsigned value on top of the evaluation stack to signed int64, throwing OverflowException on overflow. |
Conv_Ovf_U | Converts the signed value on top of the evaluation stack to unsignednatural int, throwing OverflowException on overflow. |
Conv_Ovf_U_Un | Converts the unsigned value on top of the evaluation stack to unsignednatural int, throwing OverflowException on overflow. |
Conv_Ovf_U1 | Converts the signed value on top of the evaluation stack to unsigned int8 and extends it to int32, throwing OverflowException on overflow. |
Conv_Ovf_U1_Un | Converts the unsigned value on top of the evaluation stack to unsignedint8 and extends it to int32, throwing OverflowException on overflow. |
Conv_Ovf_U2 | Converts the signed value on top of the evaluation stack to unsigned int16 and extends it to int32, throwing OverflowException on overflow. |
Conv_Ovf_U2_Un | Converts the unsigned value on top of the evaluation stack to unsigned int16 and extends it to int32, throwing OverflowException on overflow. |
Conv_Ovf_U4 | Converts the signed value on top of the evaluation stack to unsigned int32, throwing OverflowException on overflow. |
Conv_Ovf_U4_Un | Converts the unsigned value on top of the evaluation stack to unsigned int32, throwing OverflowException on overflow. |
Conv_Ovf_U8 | Converts the signed value on top of the evaluation stack to unsignedint64, throwing OverflowException on overflow. |
Conv_Ovf_U8_Un | Converts the unsigned value on top of the evaluation stack to unsigned int64, throwing OverflowException on overflow. |
Conv_R_Un | Converts the unsigned integer value on top of the evaluation stack to float32. |
Conv_R4 | Converts the value on top of the evaluation stack to float32. |
Conv_R8 | Converts the value on top of the evaluation stack to float64. |
Conv_U | Converts the value on top of the evaluation stack to unsignednatural int, and extends it to natural int. |
Conv_U1 | Converts the value on top of the evaluation stack to unsigned int8, and extends it to int32. |
Conv_U2 | Converts the value on top of the evaluation stack to unsignedint16, and extends it to int32. |
Conv_U4 | Converts the value on top of the evaluation stack to unsigned int32, and extends it to int32. |
Conv_U8 | Converts the value on top of the evaluation stack to unsignedint64, and extends it to int64. |
Cpblk | Copies a specified number bytes from a source address to a destination address . |
Cpobj | Copies the value type located at the address of an object (type &, * or natural int) to the address of the destination object (type &, * or natural int). |
Div | Divides two values and pushes the result as a floating-point (type F) or quotient (type int32) onto the evaluation stack. |
Div_Un | Divides two unsigned integer values and pushes the result (int32) onto the evaluation stack. |
Dup | Copies the current topmost value on the evaluation stack, and then pushes the copy onto the evaluation stack. |
Endfilter | Transfers control from the filter clause of an exception back to the Common Language Infrastructure (CLI) exception handler. |
Endfinally | Transfers control from the fault or finally clause of an exception block back to the Common Language Infrastructure (CLI) exception handler. |
Initblk | Initializes a specified block of memory at a specific address to a given size and initial value. |
Initobj | Initializes all the fields of the object at a specific address to a null reference or a 0 of the appropriate primitive type. |
Isinst | Tests whether an object reference (type O) is an instance of a particular class. |
Jmp | Exits current method and jumps to specified method. |
Ldarg | Loads an argument (referenced by a specified index value) onto the stack. |
Ldarg_0 | Loads the argument at index 0 onto the evaluation stack. |
Ldarg_1 | Loads the argument at index 1 onto the evaluation stack. |
Ldarg_2 | Loads the argument at index 2 onto the evaluation stack. |
Ldarg_3 | Loads the argument at index 3 onto the evaluation stack. |
Ldarg_S | Loads the argument (referenced by a specified short form index) onto the evaluation stack. |
Ldarga | Load an argument address onto the evaluation stack. |
Ldarga_S | Load an argument address, in short form, onto the evaluation stack. |
Ldc_I4 | Pushes a supplied value of type int32 onto the evaluation stack as an int32. |
Ldc_I4_0 | Pushes the integer value of 0 onto the evaluation stack as an int32. |
Ldc_I4_1 | Pushes the integer value of 1 onto the evaluation stack as an int32. |
Ldc_I4_2 | Pushes the integer value of 2 onto the evaluation stack as an int32. |
Ldc_I4_3 | Pushes the integer value of 3 onto the evaluation stack as an int32. |
Ldc_I4_4 | Pushes the integer value of 4 onto the evaluation stack as an int32. |
Ldc_I4_5 | Pushes the integer value of 5 onto the evaluation stack as an int32. |
Ldc_I4_6 | Pushes the integer value of 6 onto the evaluation stack as an int32. |
Ldc_I4_7 | Pushes the integer value of 7 onto the evaluation stack as an int32. |
Ldc_I4_8 | Pushes the integer value of 8 onto the evaluation stack as an int32. |
Ldc_I4_M1 | Pushes the integer value of -1 onto the evaluation stack as an int32. |
Ldc_I4_S | Pushes the supplied int8 value onto the evaluation stack as an int32, short form. |
Ldc_I8 | Pushes a supplied value of type int64 onto the evaluation stack as an int64. |
Ldc_R4 | Pushes a supplied value of type float32 onto the evaluation stack as type F (float). |
Ldc_R8 | Pushes a supplied value of type float64 onto the evaluation stack as type F (float). |
Ldelem_I | Loads the element with type natural int at a specified array index onto the top of the evaluation stack as a natural int. |
Ldelem_I1 | Loads the element with type int8 at a specified array index onto the top of the evaluation stack as an int32. |
Ldelem_I2 | Loads the element with type int16 at a specified array index onto the top of the evaluation stack as an int32. |
Ldelem_I4 | Loads the element with type int32 at a specified array index onto the top of the evaluation stack as an int32. |
Ldelem_I8 | Loads the element with type int64 at a specified array index onto the top of the evaluation stack as an int64. |
Ldelem_R4 | Loads the element with type float32 at a specified array index onto the top of the evaluation stack as type F (float) . |
Ldelem_R8 | Loads the element with type float64 at a specified array index onto the top of the evaluation stack as type F (float) . |
Ldelem_Ref | Loads the element containing an object reference at a specified array index onto the top of the evaluation stack as type O (object reference). |
Ldelem_U1 | Loads the element with type unsigned int8 at a specified array index onto the top of the evaluation stack as an int32. |
Ldelem_U2 | Loads the element with type unsigned int16 at a specified array index onto the top of the evaluation stack as an int32. |
Ldelem_U4 | Loads the element with type unsigned int32 at a specified array index onto the top of the evaluation stack as an int32. |
Ldelema | Loads the address of the array element at a specified array index onto the top of the evaluation stack as type & (managed pointer). |
Ldfld | Finds the value of a field in the object whose reference is currently on the evaluation stack. |
Ldflda | Finds the address of a field in the object whose reference is currently on the evaluation stack. |
Ldftn | Pushes an unmanaged pointer (type natural int) to the native code implementing a specific method onto the evaluation stack. |
Ldind_I | Loads a value of type natural int as a natural int onto the evaluation stack indirectly. |
Ldind_I1 | Loads a value of type int8 as an int32 onto the evaluation stack indirectly. |
Ldind_I2 | Loads a value of type int16 as an int32 onto the evaluation stack indirectly. |
Ldind_I4 | Loads a value of type int32 as an int32 onto the evaluation stack indirectly. |
Ldind_I8 | Loads a value of type int64 as an int64 onto the evaluation stack indirectly. |
Ldind_R4 | Loads a value of type float32 as a type F (float) onto the evaluation stack indirectly. |
Ldind_R8 | Loads a value of type float64 as a type F (float) onto the evaluation stack indirectly. |
Ldind_Ref | Loads an object reference as a type O (object reference) onto the evaluation stack indirectly. |
Ldind_U1 | Loads a value of type unsigned int8 as an int32 onto the evaluation stack indirectly. |
Ldind_U2 | Loads a value of type unsigned int16 as an int32 onto the evaluation stack indirectly. |
Ldind_U4 | Loads a value of type unsigned int32 as an int32 onto the evaluation stack indirectly. |
Ldlen | Pushes the number of elements of a zero-based, one-dimensional array onto the evaluation stack. |
Ldloc | Loads the local variable at a specific index onto the evaluation stack. |
Ldloc_0 | Loads the local variable at index 0 onto the evaluation stack. |
Ldloc_1 | Loads the local variable at index 1 onto the evaluation stack. |
Ldloc_2 | Loads the local variable at index 2 onto the evaluation stack. |
Ldloc_3 | Loads the local variable at index 3 onto the evaluation stack. |
Ldloc_S | Loads the local variable at a specific index onto the evaluation stack, short form. |
Ldloca | Loads the address of the local variable at a specific index onto the evaluation stack. |
Ldloca_S | Loads the address of the local variable at a specific index onto the evaluation stack, short form. |
Ldnull | Pushes a null reference (type O) onto the evaluation stack. |
Ldobj | Copies the value type object pointed to by an address to the top of the evaluation stack. |
Ldsfld | Pushes the value of a static field onto the evaluation stack. |
Ldsflda | Pushes the address of a static field onto the evaluation stack. |
Ldstr | Pushes a new object reference to a string literal stored in the metadata. |
Ldtoken | Converts a metadata token to its runtime representation, pushing it onto the evaluation stack. |
Ldvirtftn | Pushes an unmanaged pointer (type natural int) to the native code implementing a particular virtual method associated with a specified object onto the evaluation stack. |
Leave | Exits a protected region of code, unconditionally tranferring control to a specific target instruction. |
Leave_S | Exits a protected region of code, unconditionally tranferring control to a target instruction (short form). |
Localloc | Allocates a certain number of bytes from the local dynamic memory pool and pushes the address (a transient pointer, type *) of the first allocated byte onto the evaluation stack. |
Mkrefany | Pushes a typed reference to an instance of a specific type onto the evaluation stack. |
Mul | Multiplies two values and pushes the result on the evaluation stack. |
Mul_Ovf | Multiplies two integer values, performs an overflow check, and pushes the result onto the evaluation stack. |
Mul_Ovf_Un | Multiplies two unsigned integer values , performs an overflow check , and pushes the result onto the evaluation stack. |
Neg | Negates a value and pushes the result onto the evaluation stack. |
Newarr | Pushes an object reference to a new zero-based, one-dimensional array whose elements are of a specific type onto the evaluation stack. |
Newobj | Creates a new object or a new instance of a value type, pushing an object reference (type O) onto the evaluation stack. |
Nop | Fills space if bytecodes are patched. No meaningful operation is performed although a processing cycle can be consumed. |
Not | Computes the bitwise complement of the integer value on top of the stack and pushes the result onto the evaluation stack as the same type. |
Or | Compute the bitwise complement of the two integer values on top of the stack and pushes the result onto the evaluation stack. |
Pop | Removes the value currently on top of the evaluation stack. |
Prefix1 | This is a reserved instruction. |
Prefix2 | This is a reserved instruction. |
Prefix3 | This is a reserved instruction. |
Prefix4 | This is a reserved instruction. |
Prefix5 | This is a reserved instruction. |
Prefix6 | This is a reserved instruction. |
Prefix7 | This is a reserved instruction. |
Prefixref | This is a reserved instruction. |
Refanytype | Retrieves the type token embedded in a typed reference . |
Refanyval | Retrieves the address (type &) embedded in a typed reference. |
Rem | Divides two values and pushes the remainder onto the evaluation stack. |
Rem_Un | Divides two unsigned values and pushes the remainder onto the evaluation stack. |
Ret | Returns from the current method, pushing a return value (if present) from the caller's evaluation stack onto the callee's evaluation stack. |
Rethrow | Rethrows the current exception. |
Shl | Shifts an integer value to the left (in zeroes) by a specified number of bits, pushing the result onto the evaluation stack. |
Shr | Shifts an integer value (in sign) to the right by a specified number of bits, pushing the result onto the evaluation stack. |
Shr_Un | Shifts an unsigned integer value (in zeroes) to the right by a specified number of bits, pushing the result onto the evaluation stack. |
Sizeof | Pushes the size, in bytes, of a supplied value type onto the evaluation stack. |
Starg | Stores the value on top of the evaluation stack in the argument slot at a specified index. |
Starg_S | Stores the value on top of the evaluation stack in the argument slot at a specified index , short form . |
Stelem_I | Replaces the array element at a given index with the natural int value on the evaluation stack. |
Stelem_I1 | Replaces the array element at a given index with the int8 value on the evaluation stack. |
Stelem_I2 | Replaces the array element at a given index with the int16 value on the evaluation stack. |
Stelem_I4 | Replaces the array element at a given index with the int32 value on the evaluation stack. |
Stelem_I8 | Replaces the array element at a given index with the int64 value on the evaluation stack. |
Stelem_R4 | Replaces the array element at a given index with the float32 value on the evaluation stack. |
Stelem_R8 | Replaces the array element at a given index with the float64 value on the evaluation stack. |
Stelem_Ref | Replaces the array element at a given index with the object ref value (type O) on the evaluation stack. |
Stfld | Replaces the value stored in the field of an object reference or pointer with a new value. |
Stind_I | Stores a value of type natural int at a supplied address. |
Stind_I1 | Stores a value of type int8 at a supplied address. |
Stind_I2 | Stores a value of type int16 at a supplied address. |
Stind_I4 | Stores a value of type int32 at a supplied address. |
Stind_I8 | Stores a value of type int64 at a supplied address. |
Stind_R4 | Stores a value of type float32 at a supplied address. |
Stind_R8 | Stores a value of type float64 at a supplied address. |
Stind_Ref | Stores a object reference value at a supplied address. |
Stloc | Pops the current value from the top of the evaluation stack and stores it in a the local variable list at a specified index. |
Stloc_0 | Pops the current value from the top of the evaluation stack and stores it in a the local variable list at index 0. |
Stloc_1 | Pops the current value from the top of the evaluation stack and stores it in a the local variable list at index 1. |
Stloc_2 | Pops the current value from the top of the evaluation stack and stores it in a the local variable list at index 2. |
Stloc_3 | Pops the current value from the top of the evaluation stack and stores it in a the local variable list at index 3. |
Stloc_S | Pops the current value from the top of the evaluation stack and stores it in a the local variable list at index (short form) . |
Stobj | Copies a value of a specified type from the evaluation stack into a supplied memory address. |
Stsfld | Replaces the value of a static field with a value from the evaluation stack. |
Sub | Subtracts one value from another and pushes the result onto the evaluation stack. |
Sub_Ovf | Subtracts one integer value from another, performs an overflow check, and pushes the result onto the evaluation stack. |
Sub_Ovf_Un | Subtracts one unsigned integer value from another, performs an overflow check, and pushes the result onto the evaluation stack. |
Switch | Implements a jump table. |
Tailcall | Performs a postfixed method call instruction such that the current method's stack frame is removed before the actual call instruction is executed. |
Throw | Throws the exception object currently on the evaluation stack. |
Unaligned | Indicates that an address currently atop the evaluation stack might not be aligned to the natural size of the immediately following ldind, stind, ldfld, stfld, ldobj, stobj, initblk, or cpblk instruction. |
Unbox | Converts the boxed representation of a value type to its unboxed form. |
Volatile | Specifies that an address currently atop the evaluation stack might be volatile, and the results of reading that location cannot be cached or that multiple stores to that location cannot be suppressed. |
Xor | Computes the bitwise XOR of the top two values on the evaluation stack, pushing the result onto the evaluation stack. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
TakesSingleByteArgument | Returns true or false if the supplied opcode takes a single byte argument. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public static readonly OpCode Add;
|
Format | Assembly Format | Description |
---|---|---|
58 | add | Adds two numeric values, returning a new numeric value. |
The stack transitional behavior, in sequential order, is:
Overflow is not detected for integer operations (for proper overflow handling, see OpCodes.Add_Ovf).
Integer addition wraps, rather than saturates. 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.
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. 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 type | value2 type | result type |
---|---|---|---|
add | int32 | int32 | int32 |
add | int32 | natural int | natural int |
add | int32 | & | & |
add | int32 | * | * |
add | int64 | int64 | int64 |
add | natural int | int32 | natural int |
add | natural int | natural int | natural int |
add | natural int | & | & |
add | natural int | * | * |
add | F | F | F |
add | & | int32 | & |
add | & | natural int | & |
add | * | int32 | * |
add | * | natural int | * |
The following ILGenerator.Emit constructor overload can use the add opcode:
public static readonly OpCode Add_Ovf;
|
Format | Assembly Format | Description |
---|---|---|
D6 | add.ovf | Adds two signed integer values with an overflow check. |
The stack transitional behavior, in sequential order, is:
OverflowException is thrown if the result is not represented in the result type.
You can perform this operation on signed integers. For floating-point values, use OpCodes.Add.
The acceptable operand types and their corresponding result data type are listed in the table below. 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) instruction and generates an error.
operand | value1 type | value2 type | result type |
---|---|---|---|
add | int32 | int32 | int32 |
add | int32 | natural int | natural int |
add | int32 | & | & |
add | int32 | * | * |
add | int64 | int64 | int64 |
add | natural int | int32 | natural int |
add | natural int | natural int | natural int |
add | natural int | & | & |
add | natural int | * | * |
add | F | F | F |
add | & | int32 | & |
add | & | natural int | & |
add | * | int32 | * |
add | * | natural int | * |
The following ILGenerator.Emit constructor overload can use the add.ovf opcode:
public static readonly OpCode Add_Ovf_Un;
|
Format | Assembly Format | Description |
---|---|---|
D7 | add.ovf.un | Adds two unsigned integer values with an overflow check. |
The stack transitional behavior, in sequential order, is:
OverflowException is thrown if the result is not represented in the result type.
You can perform this operation on signed integers. For floating-point values, use OpCodes.Add.
The acceptable operand types and their corresponding result data type are listed in the table below. 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) instruction and generates an error.
operand | value1 type | value2 type | result type |
---|---|---|---|
add | int32 | int32 | int32 |
add | int32 | natural int | natural int |
add | int32 | & | & |
add | int32 | * | * |
add | int64 | int64 | int64 |
add | natural int | int32 | natural int |
add | natural int | natural int | natural int |
add | natural int | & | & |
add | natural int | * | * |
add | F | F | F |
add | & | int32 | & |
add | & | natural int | & |
add | * | int32 | * |
add | * | natural int | * |
The following ILGenerator.Emit constructor overload can use the add.ovf.un opcode:
public static readonly OpCode And;
|
Format | Instruction | Description |
---|---|---|
5F | and | Determines the bitwise AND of two integer values. |
The stack transitional behavior, in sequential order, is:
The and instruction computes the bitwise AND of the top two values on the stack and leaves the result on the stack.
And is an integer-specific operation.
The following ILGenerator.Emit constructor overload can use the and opcode:
public static readonly OpCode Arglist;
|
Format | Assembly Format | Description |
---|---|---|
FE 00 | arglist | Returns an argument list handle for the current method. |
No evaluation stack behaviors are performed by this operation.
The arglist instruction returns an opaque handle (an unmanaged pointer, of type natural int) that represents the argument list of the current method. This handle is valid only during the lifetime of the current method. You can, however, pass the handle to other methods as long as the current method is on the thread of control. You can only execute the arglist instruction within a method that takes a variable number of arguments.
The following ILGenerator.Emit constructor overload can use the arglist opcode:
public static readonly OpCode Beq;
|
Format | Assembly Format | Description |
---|---|---|
3B < int32 > | beq | Branch to the target instruction at offset if the two values are equal. |
The stack transitional behavior, in sequential order, is:
The beq instruction transfers control to the specified target instruction if value1 is equal to value2. The effect is the same as performing a ceq instruction followed by a brtrue branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
The acceptable operand types are encapsulated below:
If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes.
Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction (such transfers are severely restricted and must use the OpCodes.Leave instruction instead).
The following ILGenerator.Emit constructor overload can use the beq opcode:
public static readonly OpCode Beq_S;
|
Format | Assembly Format | Description |
---|---|---|
2E < int8 > | beq.s | Branch to the target instruction at offset if equal, short form |
The stack transitional behavior, in sequential order, is:
The beq.s instruction transfers control to to the specified target instruction if value1 is equal to value2. The effect is the same as performing a ceq instruction followed by a brtrue branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
The acceptable operand types are encapsulated below:
If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes.
Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction (such transfers are severely restricted and must use the OpCodes.Leave instruction instead).
The following ILGenerator.Emit constructor overload can use the beq.s opcode:
public static readonly OpCode Bge;
|
Format | Assembly Format | Description |
---|---|---|
3C <int32> | bge | Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value |
The stack transitional behavior, in sequential order, is:
The bge instruction transfers control to the specified target instruction if value1 is greater than or equal to value2. The effect is identical to performing a clt.un instruction followed by a brfalse branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the bge opcode:
public static readonly OpCode Bge_S;
|
Format | Assembly Format | Description |
---|---|---|
2F <int8> | bge.s | Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value, short form. |
The stack transitional behavior, in sequential order, is:
The bge.s instruction transfers control to the specified target instruction if value1 is greater than or equal to value2. The effect is identical to performing a clt.un instruction followed by a brfalse branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the bge.s opcode:
public static readonly OpCode Bge_Un;
|
Format | Assembly Format | Description |
---|---|---|
41 <int32> | bge.un | Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value (unsigned values). |
The stack transitional behavior, in sequential order, is:
The bge.un instruction transfers control to the specified target instruction if value1 is greater than or equal to value2, when compared using unsigned integer or unordered float values. The effect is identical to performing a clt instruction followed by a brfalse branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the bge.un opcode:
public static readonly OpCode Bge_Un_S;
|
Format | Assembly Format | Description |
---|---|---|
34 < int8 > | bge.un.s | Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value (unsigned values), short form. |
The stack transitional behavior, in sequential order, is:
The bge.un.s instruction transfers control to the specified target instruction if value1 is greater than or equal to value2, when compared using unsigned integer or unordered float values. The effect is identical to performing a clt instruction followed by a brfalse branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the bge.un.s opcode:
public static readonly OpCode Bgt;
|
Format | Assembly Format | Description |
---|---|---|
3D < int32 > | bgt | Branch to the target instruction at the specified offset if the first value is greater than the second value. |
The stack transitional behavior, in sequential order, is:
The bgt instruction transfers control to the specified target instruction if value1 is greater than value2. The effect is identical to performing a cgt instruction followed by a brtrue branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the bgt opcode:
public static readonly OpCode Bgt_S;
|
Format | Assembly Format | Description |
---|---|---|
30 < int8 > | bgt.s | Branch to the target instruction at the specified offset if the first value is greater than the second value, short form. |
The stack transitional behavior, in sequential order, is:
The bgt.s instruction transfers control to the specified target instruction if value1 is greater than value2. The effect is identical to performing a cgt instruction followed by a brtrue branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the bgt.s opcode:
public static readonly OpCode Bgt_Un;
|
Format | Assembly Format | Description |
---|---|---|
42 < int32 > | bgt.un | Branch to the target instruction at the specified offset if the first value is greater than the second value (unsigned values). |
The stack transitional behavior, in sequential order, is:
The bgt.un instruction transfers control to the specified target instruction if value1 is greater than value2, when compared using unsigned integer or unordered float values. The effect is identical to performing a cgt.un instruction followed by a brtrue branch to the specific target instruction.. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the bgt.un opcode:
public static readonly OpCode Bgt_Un_S;
|
Format | Assembly Format | Description |
---|---|---|
35 < int8 > | bgt.un.s | Branch to the target instruction at the specified offset if the first value is greater than the second value (unsigned values), short form. |
The stack transitional behavior, in sequential order, is:
The bgt.un.s instruction transfers control to the specified target instruction if value1 is greater than value2, when compared using unsigned integer or unordered float values. The effect is identical to performing a cgt.un instruction followed by a brtrue branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the bgt.un.s opcode:
public static readonly OpCode Ble;
|
Format | Assembly Format | Description |
---|---|---|
3E <int32> | ble | Branch to the target instruction at the specified offset if the first value is less than or equal to the second value. |
The stack transitional behavior, in sequential order, is:
The ble instruction transfers control to the specified target instruction if value1 is less than or equal to value2. The effect is identical to performing a cgt instruction (cgt.un for floats) followed by a brfalse branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the ble opcode:
public static readonly OpCode Ble_S;
|
Format | Assembly Format | Description |
---|---|---|
31 <int8> | ble.s | Branch to the target instruction at the specified offset if the first value is less than or equal to the second value, short form. |
The stack transitional behavior, in sequential order, is:
The ble.s instruction transfers control to the specified target instruction if value1 is less than or equal to value2. The effect is identical to performing a cgt instruction (cgt.un for floats) instruction followed by a brfalse branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the ble.s opcode:
public static readonly OpCode Ble_Un;
|
Format | Assembly Format | Description |
---|---|---|
43 <int32> | ble.un | Branch to the target instruction at the specified offset if the first value is less than or equal to the second value (unsigned values). |
The stack transitional behavior, in sequential order, is:
The ble.un instruction transfers control to the specified target instruction if value1 is less than or equal to value2, when compared using unsigned integer or unordered float values. The effect is identical to performing a cgt.un instruction (cgt for floats) followed by a brfalse branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the ble.un opcode:
public static readonly OpCode Ble_Un_S;
|
Format | Assembly Format | Description |
---|---|---|
36 <int8> | ble.un.s | Branch to the target instruction at the specified offset if the first value is less than or equal to the second value (unsigned values), short form. |
The stack transitional behavior, in sequential order, is:
The ble.un.s instruction transfers control to the specified target instruction if value1 is less than or equal to value2, when compared using unsigned integer or unordered float values. The effect is identical to performing a cgt.un instruction (cgt for floats) followed by a brfalse branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the ble.un.s opcode:
public static readonly OpCode Blt;
|
Format | Assembly Format | Description |
---|---|---|
3F < int32 > | blt | Branch to the target instruction at the specified offset if the first value is less than the second value. |
The stack transitional behavior, in sequential order, is:
The blt instruction transfers control to the specified target instruction if value1 is less than or equal to value2. The effect is identical to performing a clt instruction followed by a brtrue branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the blt opcode:
public static readonly OpCode Blt_S;
|
Format | Assembly Format | Description |
---|---|---|
32 < int8 > | blt.s | Branch to the target instruction at the specified offset if the first value is less than the second value, short form. |
The stack transitional behavior, in sequential order, is:
The blt.s instruction transfers control to the specified target instruction if value1 is less than value2. The effect is identical to performing a clt instruction followed by a brtrue branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the blt.s opcode:
public static readonly OpCode Blt_Un;
|
Format | Assembly Format | Description |
---|---|---|
44 < int32 > | blt.un | Branch to the target instruction at the specified offset if the first value is less than the second value (unsigned values). |
The stack transitional behavior, in sequential order, is:
The blt.un instruction transfers control to the specified target instruction if value1 is less than value2, when compared using unsigned integer or unordered float values. The effect is identical to performing a clt.un instruction followed by a brtrue branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the blt.un opcode:
public static readonly OpCode Blt_Un_S;
|
Format | Assembly Format | Description |
---|---|---|
37 < int8 > | blt.un.s | Branch to the target instruction at the specified offset if the first value is less than the second value (unsigned values), short form. |
The stack transitional behavior, in sequential order, is:
The blt.un instruction transfers control to the specified target instruction if value1 is less than value2, when compared using unsigned integer or unordered float values. The effect is identical to performing a clt.un instruction followed by a brtrue branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the blt.un.s opcode:
public static readonly OpCode Bne_Un;
|
Format | Assembly Format | Description |
---|---|---|
40 < int32 > | bne.un | Branch to the target instruction at the specified offset if two unsigned integer values are not equal (unsigned values). |
The stack transitional behavior, in sequential order, is:
The bne.un instruction transfers control to the specified target instruction if value1 is not equal to value2, when compared using unsigned integer or unordered float values. The effect is identical to performing a ceq.un instruction followed by a brfalse branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the bne.un opcode:
public static readonly OpCode Bne_Un_S;
|
Format | Assembly Format | Description |
---|---|---|
33 < int8 > | bne.un.s | Branch to the target instruction at the specified offset if two unsigned integer values are not equal (unsigned values), short form. |
The stack transitional behavior, in sequential order, is:
The bne.un instruction transfers control to the specified target instruction if value1 is not equal to value2, when compared using unsigned integer or unordered float values. The effect is identical to performing a ceq.un instruction followed by a brfalse branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the bne.un.s opcode:
public static readonly OpCode Box;
|
Format | Assembly Format | Description |
---|---|---|
8C < T > | box | Convert a value type (of the type specified in ) to a true object reference. |
The stack transitional behavior, in sequential order, is:
A value type has two separate representations within the Common Language Infrastructure (CLI):
The box instruction converts the 'raw' (unboxed) value type into an object reference (type O). This is accomplished by creating a new object and copying the data from the value type into the newly allocated object.valTypeToken is a metadata token indicating the type of the value type on the stack.
OutOfMemoryException is thrown if there is insufficient memory to satisfy the request.
TypeLoadException is thrown if the class cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) is converted to native code, rather than at runtime.
The following ILGenerator.Emit constructor overload can use the box opcode:
public static readonly OpCode Br;
|
Format | Assembly Format | Description |
---|---|---|
38 < int32 > | br | Branches to a target instruction at the specified offset |
No evaluation stack behaviors are performed by this operation.
The br instruction unconditionally transfers control to a target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the br opcode:
public static readonly OpCode Br_S;
|
Format | Assembly Format | Description |
---|---|---|
2B < int8 > | br.s | Branches to a target instruction at the specified offset short form. |
No evaluation stack behaviors are performed by this operation.
The br.s instruction unconditionally transfers control to a target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the br.s opcode:
public static readonly OpCode Break;
|
Format | Assembly Format | Description |
---|---|---|
01 | break | inform a debugger that a breakpoint has been reached. |
No evaluation stack behaviors are performed by this operation.
The break instruction is for debugging support. It signals the CLI to inform the debugger that a break point has been tripped. It has no other effect on the interpreter state.
The break instruction has the smallest possible instruction size enabling code patching with a break point and generating minimal disturbance to the surrounding code.
The break instruction can trap to a debugger, do nothing, or raise a security exception. The exact behavior is implementation-defined.
The following ILGenerator.Emit constructor overload can use the break opcode:
public static readonly OpCode Brfalse;
|
Format | Assembly Format | Description |
---|---|---|
39 < int32 > | brfalse target brnull target brzero target | Branches to a target instruction at the specified offset if false . |
The stack transitional behavior, in sequential order, is:
The brfalse instruction (and its aliases brnull and brzero) transfers control to the specified target instruction if value (of type int32, int64, object reference O, managed pointer &, transient pointer *, natural int) is zero (false). If value is non-zero (true) execution continues at the next instruction.
The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the brfalse opcode:
public static readonly OpCode Brfalse_S;
|
Format | Assembly Format | Description |
---|---|---|
2C < int8 > | brfalse.s target brnull.s target brzero.s target | Branches to a target instruction at the specified offset if false , short form. |
The stack transitional behavior, in sequential order, is:
The brfalse.s instruction (and its aliases brnull and brzero) transfers control to the specified target instruction if value (of type int32, int64, object reference O, managed pointer &, transient pointer *, natural int) is zero (false). If value is non-zero (true) execution continues at the next instruction.
The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the brfalse.s opcode:
public static readonly OpCode Brtrue;
|
Format | Assembly Format | Description |
---|---|---|
3A < int32 > | brtrue target brinst target | Branch to a target instruction at the specified offset if non-zero ( true ). |
The stack transitional behavior, in sequential order, is:
The brtrue instruction transfers control to the specified target instruction if value (type natural int) is nonzero (true). If value is zero (false) execution continues at the next instruction.
If value is an object reference (type O) then brinst (an alias for brtrue) transfers control if it represents an instance of an object (for example, if it is not the null object reference; see OpCodes.Ldnull).
The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the brtrue opcode:
public static readonly OpCode Brtrue_S;
|
Format | Assembly Format | Description |
---|---|---|
2D < int8 > | brtrue.s target brinst.s target | Branch to a target instruction at the specified offset if non-zero ( true ), short form. |
The stack transitional behavior, in sequential order, is:
The brtrue.s instruction transfers control to the specified target instruction if value (type natural int) is nonzero (true). If value is zero (false) execution continues at the next instruction.
If value is an object reference (type O) then brinst (an alias for brtrue) transfers control if it represents an instance of an object (for example, if it is not the null object reference; see OpCodes.Ldnull).
The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
Control can only be transferred to the first of these prefixes if the target instruction has one or more prefix codes. Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction.
The following ILGenerator.Emit constructor overload can use the brtrue.s opcode:
public static readonly OpCode Call;
|
Format | Assembly Format | Description |
---|---|---|
28 < T > | call | Call the method described by |
The stack transitional behavior, in sequential order, is:
The call instruction calls the method indicated by the method descriptor passed with the instruction. The method descriptor is a metadata token that indicates the method to call and the number, type, and order of the arguments that have been placed on the stack to be passed to that method as well as the calling convention to be used. The call instruction can be immediately preceded by a tail. ( OpCodes.Tailcall) prefix instruction to specify that the current method state should be released before transferring control. If the call transfers control to a method of higher trust than the origin method, the stack frame is not released. Instead, the execution continues silently as if the tail. had not been supplied. The metadata token carries sufficient information to determine whether the call is to a static method, an instance method, a virtual method, or a global function. In all of these cases the destination address is determined entirely from the method descriptor (contrast this with the OpCodes.Callvirt instruction for calling virtual methods, where the destination address also depends upon the runtime type of the instance reference pushed before the OpCodes.Callvirt).
The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. There are three important special cases:
1. Calls to an instance (or virtual) method must push that instance reference before any of the user-visible arguments. The instance reference must not be a null reference. The signature carried in the metadata does not contain an entry in the parameter list for the this pointer; instead, it uses a bit to indicate whether the method requires passing the this pointer.
2. It is valid to call a virtual method using call (rather than callvirt); this indicates that the method is to be resolved using the class specified by method rather than as specified dynamically from the object being invoked.
3. Note that a delegate's Invoke method can be called with either the call or callvirt instruction.
SecurityException may be thrown if system security does not grant the caller access to the called method. The security check may occur when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime.
The following ILGenerator.Emit constructor overload can use the call opcode:
public static readonly OpCode Calli;
|
Format | Assembly Format | Description |
---|---|---|
29 < T > | calli | Calls the method pointed to with arguments described by the calling convention. |
The stack transitional behavior, in sequential order, is:
The calli instruction calls the method entry pointer with the arguments arg1 through argN. The types of these arguments are described by the specific calling convention (callSiteDesc). The calli instruction may be immediately preceded by a tail. prefix ( OpCodes.Tailcall) to specify that the current method state should be released before transferring control. If the call would transfer control to a method of higher trust than the origin method the stack frame will not be released; instead, the execution will continue silently as if the tail. had not been supplied.
The method entry pointer is assumed to be a specific pointer to native code (of the target machine) that can be legitimately called with the arguments described by the calling convention (a metadata token for a stand-alone signature). Such a pointer can be created using the OpCodes.Ldftn or OpCodes.Ldvirtftn instructions, or passed in from native code.
The calling convention is not checked dynamically, so code that uses a calli instruction does not work correctly if the destination does not actually use the specified calling convention.
The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. The argument-building code sequence for an instance or virtual method must push that instance reference (which must not be a null reference) before any of the user-visible arguments.
SecurityException may be thrown if the system security does not grant the caller access to the called method. The security check can occur when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime.
The following ILGenerator.EmitCalli methods can be used to perform a calli instruction on the stack. Note that calli should be called through the below methods rather than using the ILGenerator.Emit class to place the instruction directly on the stack.
public static readonly OpCode Callvirt;
|
Format | Assembly Format | Description |
---|---|---|
6F < T > | callvirt | Calls a specific method associated with |
The stack transitional behavior, in sequential order, is:
The callvirt instruction calls a late-bound method on an object. That is, the method is chosen based on the runtime type of obj rather than the compile-time class visible in the method pointer.Callvirt can be used to call both virtual and instance methods. The callvirt instruction may be immediately preceded by a tail. ( OpCodes.Tailcall) prefix to specify that the current stack frame should be released before transferring control. If the call would transfer control to a method of higher trust than the original method the stack frame will not be released.
The method metadata token provides the name, class and signature of the method to call. The class associated with obj is the class of which it is an instance. If the class defines a non-static method that matches the indicated method name and signature, this method is called. Otherwise all classes in the base class chain of this class are checked in order. It is an error if no method is found.
Callvirt pops the object and the associated arguments off the evaluation stack before calling the method. If the method has a return value, it is pushed on the stack upon method completion. On the callee side, the obj parameter is accessed as argument 0, arg1 as argument 1, and so on.
The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. The instance reference obj (always required for callvirt) must be pushed before any of the user-visible arguments. The signature (carried in the metadata token) need not contain an entry in the parameter list for the this pointer.
Note that a virtual method can also be called using the OpCodes.Call instruction.
MissingMethodException is thrown if a non-static method with the indicated name and signature could not be found in the class associated with obj or any of its base classes. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code, rather than at runtime.
NullReferenceException is thrown if obj is null.
SecurityException is thrown if system security does not grant the caller access to the called method. The security check may occur when the CIL is converted to native code rather than at runtime.
The following ILGenerator.Emit constructor overload can use the callvirt opcode:
public static readonly OpCode Castclass;
|
Format | Assembly Format | Description |
---|---|---|
74 < T > | castclass | Casts an object to a new object of type . |
The stack transitional behavior, in sequential order, is:
The castclass instruction attempts to cast the object reference (type O) atop the stack to a specified class. The new class is specified by a metadata token indicating the desired class. If the class of the object on the top of the stack does not implement the new class (assuming the new class is an interface) and is not a derived class of the new class then an InvalidCastException is thrown. If the object reference is a null reference, castclass succeeds and returns the new object as a null reference.
InvalidCastException is thrown if obj cannot be cast to class.
TypeLoadException is thrown if class cannot be found. This is typically detected when a Microsoft Intermediate Language (MSIL)instruction is converted to native code rather than at runtime.
The following ILGenerator.Emit constructor overload can use the castclass opcode:
public static readonly OpCode Ceq;
|
Format | Assembly Format | Description |
---|---|---|
FE 01 | ceq | Pushes 1 if equals else pushes 0. |
The stack transitional behavior, in sequential order, is:
The ceq instruction compares value1 and value2. If value1 is equal to value2, then 1 (of type int32) is pushed on the stack. Otherwise 0 (of type int32) is pushed on the stack.
For floating-point number, ceq will return 0 if the numbers are unordered (either or both are NaN). The infinite values are equal to themselves.
The following ILGenerator.Emit constructor overload can use the ceq opcode:
public static readonly OpCode Cgt;
|
Format | Assembly Format | Description |
---|---|---|
FE 02 | cgt | Pushes 1 if is greater than else pushes 0. |
The stack transitional behavior, in sequential order, is:
The cgt instruction compares value1 and value2. If value1 is strictly greater than value2, then an int32 value of 1 is pushed on the stack. Otherwise, an int32 value of 0 is pushed on the stack.
The following ILGenerator.Emit constructor overload can use the cgt opcode:
public static readonly OpCode Cgt_Un;
|
Format | Assembly Format | Description |
---|---|---|
FE 03 | cgt.un | Pushes 1 if is greater than ; else pushes 0 (unsigned values). |
The stack transitional behavior, in sequential order, is:
An int32 value of 1 is pushed on the stack if any of the following is true:
For floating-point numbers, value1 is not ordered with respect to value2.For integer values, value1 is strictly greater than value2 when considered as unsigned numbers.
Otherwise an int32 value of 0 is pushed on the stack.
The following ILGenerator.Emit constructor overload can use the cgt.un opcode:
public static readonly OpCode Ckfinite;
|
Format | Assembly Format | Description |
---|---|---|
C3 | ckfinite | throw ArithmeticException if value is not a finite number. |
The stack transitional behavior, in sequential order, is:
The ckfinite instruction throws ArithmeticException if value (a floating-point number) is either a "not a number" value (NaN) or a +- infinity value.Ckfinite leaves the value on the stack if no exception is thrown. Execution is unspecified if value is not a floating-point number.
ArithmeticException is thrown if value is not a 'normal' number.
Note that a special exception or a derived class of ArithmeticException may be more appropriate, passing the incorrect value to the exception handler.
The following ILGenerator.Emit constructor overload can use the ckfinite opcode:
public static readonly OpCode Clt;
|
Format | Assembly Format | Description |
---|---|---|
FE 04 | clt | Pushes 1 if is less than else pushes 0. |
The stack transitional behavior, in sequential order, is: value1 is pushed onto the stack.
The clt instruction compares value1 and value2. If value1 is strictly less than value2, then an int32 value of 1 is pushed on the stack. Otherwise, an int32 value of 0 is pushed on the stack.
The following ILGenerator.Emit constructor overload can use the clt opcode:
public static readonly OpCode Clt_Un;
|
Format | Assembly Format | Description |
---|---|---|
FE 03 | clt.un | Pushes 1 if is less than else pushes 0 (unsigned values). |
The stack transitional behavior, in sequential order, is:
The clt.un instruction compares value1 and value2. An int32 value of 1 is pushed on the stack if any of the following is true:
Otherwise, an int32 value of 0 is pushed on the stack.
The following ILGenerator.Emit constructor overload can use the clt.un opcode:
public static readonly OpCode Conv_I;
|
Format | Assembly Format | Description |
---|---|---|
D3 | conv.i | Convert to natural int , pushing natural int on stack. |
The stack transitional behavior, in sequential order, is:
The conv.i opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field. See OpCodes.Conv_Ovf_I and OpCodes.Conv_Ovf_I_Un for equivalent instructions that will throw an exception when the result type can not properly represent the result value.
The following ILGenerator.Emit constructor overload can use the conv.i opcode:
public static readonly OpCode Conv_I1;
|
Format | Assembly Format | Description |
---|---|---|
67 | conv.i1 | Convert to int8 , pushing int32 on stack. |
The stack transitional behavior, in sequential order, is:
The conv.i1 opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field. See OpCodes.Conv_Ovf_I1 and OpCodes.Conv_Ovf_I1_Un for equivalent instructions that will throw an exception when the result type can not properly represent the result value.
The following ILGenerator.Emit constructor overload can use the conv.i1 opcode:
public static readonly OpCode Conv_I2;
|
Format | Assembly Format | Description |
---|---|---|
68 | conv.i2 | Convert to int16 , pushing int32 on stack. |
The stack transitional behavior, in sequential order, is:
The conv.i2 opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field. See OpCodes.Conv_Ovf_I2 and OpCodes.Conv_Ovf_I2_Un for equivalent instructions that will throw an exception when the result type can not properly represent the result value.
The following ILGenerator.Emit constructor overload can use the conv.i2 opcode:
public static readonly OpCode Conv_I4;
|
Format | Assembly Format | Description |
---|---|---|
69 | conv.i4 | Convert to int32 , pushing int32 on stack. |
The stack transitional behavior, in sequential order, is:
The conv.i4 opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field. See OpCodes.Conv_Ovf_I4 and OpCodes.Conv_Ovf_I4_Un for equivalent instructions that will throw an exception when the result type can not properly represent the result value.
The following ILGenerator.Emit constructor overload can use the conv.i4 opcode:
public static readonly OpCode Conv_I8;
|
Format | Assembly Format | Description |
---|---|---|
6A | conv.i8 | Convert to int64 , pushing int64 on stack. |
The stack transitional behavior, in sequential order, is:
The conv.i8 opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field. See OpCodes.Conv_Ovf_I8 and OpCodes.Conv_Ovf_I8_Un for equivalent instructions that will throw an exception when the result type can not properly represent the result value.
The following ILGenerator.Emit constructor overload can use the conv.i8 opcode:
public static readonly OpCode Conv_Ovf_I;
|
Format | Assembly Format | Description |
---|---|---|
D4 | conv.ovf.i | Convert to a natural int (on the stack as natural int ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.i opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.i opcode:
public static readonly OpCode Conv_Ovf_I_Un;
|
Format | Assembly Format | Description |
---|---|---|
8A | conv.ovf.i.un | Converts an unsigned value to a natural int (on the stack as natural int ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.i.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.i.un opcode:
public static readonly OpCode Conv_Ovf_I1;
|
Format | Assembly Format | Description |
---|---|---|
B3 | conv.ovf.i1 | Convert to an int8 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.i1 opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.i1 opcode:
public static readonly OpCode Conv_Ovf_I1_Un;
|
Format | Assembly Format | Description |
---|---|---|
82 | conv.ovf.i1.un | Converts an unsigned value to an int8 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.i1.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.i1.un opcode:
public static readonly OpCode Conv_Ovf_I2;
|
Format | Assembly Format | Description |
---|---|---|
B5 | conv.ovf.i2 | Convert to an int16 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.i2 opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.i2 opcode:
public static readonly OpCode Conv_Ovf_I2_Un;
|
Format | Assembly Format | Description |
---|---|---|
83 | conv.ovf.i2.un | Converts an unsigned value to an int16 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.i2.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.i2.un opcode:
public static readonly OpCode Conv_Ovf_I4;
|
Format | Assembly Format | Description |
---|---|---|
B7 | conv.ovf.i4 | Convert to an int32 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.i4 opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.i4 opcode:
public static readonly OpCode Conv_Ovf_I4_Un;
|
Format | Assembly Format | Description |
---|---|---|
84 | conv.ovf.i4.un | Converts an unsigned value to an int32 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.i4.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.i4.un opcode:
public static readonly OpCode Conv_Ovf_I8;
|
Format | Assembly Format | Description |
---|---|---|
B9 | conv.ovf.i8 | Convert to an int64 (on the stack as int64 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.i8 opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.i8 opcode:
public static readonly OpCode Conv_Ovf_I8_Un;
|
Format | Assembly Format | Description |
---|---|---|
85 | conv.ovf.i8.un | Converts an unsigned value to an int64 (on the stack as int64 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.i8.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.i8.un opcode:
public static readonly OpCode Conv_Ovf_U;
|
Format | Assembly Format | Description |
---|---|---|
D5 | conv.ovf.u | Convert to an unsignednatural int (on the stack as natural int ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.u opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.u opcode:
public static readonly OpCode Conv_Ovf_U_Un;
|
Format | Assembly Format | Description |
---|---|---|
8B | conv.ovf.u.un | Converts un unsigned value to an unsigned naturalint (on the stack as natural int ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.u.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.uvf.u.un opcode:
public static readonly OpCode Conv_Ovf_U1;
|
Format | Assembly Format | Description |
---|---|---|
B4 | conv.ovf.u1 | Convert to an unsignedint8 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.u1 opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.u1 opcode:
public static readonly OpCode Conv_Ovf_U1_Un;
|
Format | Assembly Format | Description |
---|---|---|
86 | conv.ovf.u1.un | Converts an unsigned value to an unsigned int8 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.u1.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.u1.un opcode:
public static readonly OpCode Conv_Ovf_U2;
|
Format | Assembly Format | Description |
---|---|---|
B6 | conv.ovf.u2 | Convert to an unsignedint16 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.u2 opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.u2 opcode:
public static readonly OpCode Conv_Ovf_U2_Un;
|
Format | Assembly Format | Description |
---|---|---|
87 | conv.ovf.u2.un | Converts an unsigned value to an unsignedint16 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.u2.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.u2.un opcode:
public static readonly OpCode Conv_Ovf_U4;
|
Format | Assembly Format | Description |
---|---|---|
B8 | conv.ovf.u4 | Convert to an unsignedint32 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.u4 opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.u4 opcode:
public static readonly OpCode Conv_Ovf_U4_Un;
|
Format | Assembly Format | Description |
---|---|---|
88 | conv.ovf.u4.un | Converts an unsigned value to an unsigned int32 (on the stack as int32 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.u4.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.u4.un opcode:
public static readonly OpCode Conv_Ovf_U8;
|
Format | Assembly Format | Description |
---|---|---|
BA | conv.ovf.u8 | Convert to an unsignedint64 (on the stack as int64 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.u8 opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.u8 opcode:
public static readonly OpCode Conv_Ovf_U8_Un;
|
Format | Assembly Format | Description |
---|---|---|
89 | conv.ovf.u8.un | Converts an unsigned value to an unsignedint64 (on the stack as int64 ) and throw an exception on overflow. |
The stack transitional behavior, in sequential order, is:
The conv.ovf.u8.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. If the value is too large or too small to be represented by the target type, an exception is thrown.
Conversions from floating-point numbers to integer values truncate the number toward zero. Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also natural int).
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the conv.ovf.u8.un opcode:
public static readonly OpCode Conv_R_Un;
|
Format | Assembly Format | Description |
---|---|---|
76 | conv.r.un | Convert unsigned integer to floating-point, pushing F on stack. |
The stack transitional behavior, in sequential order, is:
The conv.r.un opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the result returned is unspecified. The conv.r.un operation takes an integer off the stack, interprets it as unsigned, and replaces it with a floating-point number to represent the integer: either a float32, if this is wide enough to represent the integer without loss of precision, or else a float64.
No exceptions are ever thrown when using this field.
The following ILGenerator.Emit constructor overload can use the conv.r.un opcode:
public static readonly OpCode Conv_R4;
|
Format | Assembly Format | Description |
---|---|---|
6B | conv.r4 | Convert to float32 , pushing F on stack. |
The stack transitional behavior, in sequential order, is:
The conv.r4 opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field.
The following ILGenerator.Emit constructor overload can use the conv.r4 opcode:
public static readonly OpCode Conv_R8;
|
Format | Assembly Format | Description |
---|---|---|
6C | conv.r8 | Convert to float64 , pushing F on stack. |
The stack transitional behavior, in sequential order, is:
The conv.r8 opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field.
The following ILGenerator.Emit constructor overload can use the conv.r8 opcode:
public static readonly OpCode Conv_U;
|
Format | Assembly Format | Description |
---|---|---|
E0 | conv.u | Convert to unsigned natural int , pushing natural int on stack. |
The stack transitional behavior, in sequential order, is:
1)value is pushed onto the stack.
2)value is popped from the stack and the conversion operation is attempted.
3) If the conversion is successful, the resulting value is pushed onto the stack.
The conv.u opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field. See OpCodes.Conv_Ovf_I and OpCodes.Conv_Ovf_I_Un for equivalent instructions that will throw an exception when the result type can not properly represent the result value.
The following ILGenerator.Emit constructor overload can use the conv.u opcode:
public static readonly OpCode Conv_U1;
|
Format | Assembly Format | Description |
---|---|---|
D2 | conv.u1 | Convert to int8 , pushing int32 on stack. |
The stack transitional behavior, in sequential order, is:
The conv.u1 opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field. See OpCodes.Conv_Ovf_I1 and OpCodes.Conv_Ovf_I1_Un for equivalent instructions that will throw an exception when the result type can not properly represent the result value.
The following ILGenerator.Emit constructor overload can use the conv.u1 opcode:
public static readonly OpCode Conv_U2;
|
Format | Assembly Format | Description |
---|---|---|
D1 | conv.u2 | Convert to int16 , pushing int32 on stack. |
The stack transitional behavior, in sequential order, is:
The conv.u2 opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field. See OpCodes.Conv_Ovf_I2 and OpCodes.Conv_Ovf_I2_Un for equivalent instructions that will throw an exception when the result type can not properly represent the result value.
The following ILGenerator.Emit constructor overload can use the conv.u2 opcode:
public static readonly OpCode Conv_U4;
|
Format | Assembly Format | Description |
---|---|---|
6D | conv.u4 | Convert to unsignedint32 , pushing int32 on stack. |
The stack transitional behavior, in sequential order, is:
The conv.u4 opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field. See OpCodes.Conv_Ovf_I4 and OpCodes.Conv_Ovf_I4_Un for equivalent instructions that will throw an exception when the result type can not properly represent the result value.
The following ILGenerator.Emit constructor overload can use the conv.u4 opcode:
public static readonly OpCode Conv_U8;
|
Format | Assembly Format | Description |
---|---|---|
6E | conv.u8 | Convert to int64 , pushing int64 on stack. |
The stack transitional behavior, in sequential order, is:
The conv.u8 opcode converts the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.i or conv.u is used, in which case the result is also natural int). Floating-point values are converted to the F type.
Conversion from floating-point numbers to integer values truncates the number toward zero. When converting from an float64 to an float32, precision can be lost. If value is too large to fit in a float32 (F), positive infinity (if value is positive) or negative infinity (if value is negative) is returned. If overflow occurs converting one integer type to another, the high order bits are truncated. If the result is smaller than an int32, the value is sign-extended to fill the slot.
If overflow occurs converting a floating-point type to an integer the value returned is unspecified.
No exceptions are ever thrown when using this field. See OpCodes.Conv_Ovf_I8 and OpCodes.Conv_Ovf_I8_Un for equivalent instructions that will throw an exception when the result type can not properly represent the result value.
The following ILGenerator.Emit constructor overload can use the conv.u8 opcode:
public static readonly OpCode Cpblk;
|
Format | Assembly Format | Description |
---|---|---|
FE 17 | cpblk | Copy data from one memory block to another. |
The stack transitional behavior, in sequential order, is:
The cpblk instruction copies a number (type unsigned int32) of bytes from a source address (of type *, natural int, or &) to a destination address (of type *, natural int, or &). The behavior of cpblk is unspecified if the source and destination areas overlap.
cpblk assumes that both the source and destination addressed are aligned to the natural size of the machine. The cpblk instruction can be immediately preceded by the unaligned.<prefix> instruction to indicate that either the source or the destination is unaligned.
The operation of the cpblk instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
NullReferenceException may be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the cpblk opcode:
public static readonly OpCode Cpobj;
|
Format | Assembly Format | Description |
---|---|---|
70 < T > | cpobj | Copies a value type from a source object to a destination object. |
The stack transitional behavior, in sequential order, is:
The behavior of cpobj is unspecified if the source and destination object references are not pointers to instances of the class represented by the class token classTok (a typeref or typedef), or if classTok does not represent a value type.
NullReferenceException may be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the cpobj opcode:
public static readonly OpCode Div;
|
Format | Assembly Format | Description |
---|---|---|
5B | div | Divides two values to return a quotient or floating-point result. |
The stack transitional behavior, in sequential order, is:
result = value1 div value2 satisfies the following conditions:
| result | = | value1 | / | value2 |, and:
sign(result) = +, if sign(value1) = sign(value2), or -, if sign(value1) ~= sign(value2)
The div instruction computes the result and pushes it on the stack.
Integer division truncates towards zero.
Division of a finite number by zero produces the correctly signed infinite value.
Dividing zero by zero or infinity by infinity produces the NaN (Not-A-Number) value. Any number divided by infinity will produce a zero value.
Integral operations throw ArithmeticException if the result cannot be represented in the result type. This can happen if value1 is the maximum negative value, and value2 is -1.
Integral operations throw DivideByZeroException if value2 is zero.
Note that on Intel-based platforms an OverflowException is thrown when computing (minint div -1). Floating-point operations never throw an exception (they produce NaNs or infinities instead).
The following ILGenerator.Emit constructor overload can use the div opcode:
public static readonly OpCode Div_Un;
|
Format | Assembly Format | Description |
---|---|---|
5C | div.un | Divides two values, unsigned, returning a quotient. |
The stack transitional behavior, in sequential order, is:
The div.un instruction computes value1 divided by value2, both taken as unsigned integers, and pushes the result on the stack.
The following ILGenerator.Emit constructor overload can use the div.un opcode:
public static readonly OpCode Dup;
|
Format | Assembly Format | Description |
---|---|---|
25 | dup | Duplicates the value on the top of the stack. |
The stack transitional behavior, in sequential order, is:
The dup instruction duplicates the top element of the stack, and leaves two identical values atop it.
The following ILGenerator.Emit constructor overload can use the dup opcode:
public static readonly OpCode Endfilter;
|
Format | Assembly Format | Description |
---|---|---|
FE 11 | endfilter | End filter clause of SEH exception handling. |
The stack transitional behavior, in sequential order, is:
Value (which must be of type int32 and is one of a specific set of values) is returned from the filter clause. It should be one of:
Other integer values will produce unspecified results.
The entry point of a filter, as shown in the method's exception table, must be the first instruction in the filter's code block. The endfilter instruction must be the last instruction in the filter's code block (hence there can only be one endfilter for any single filter block). After executing the endfilter instruction, control logically flows back to the CLI exception handling mechanism.
Control cannot be transferred into a filter block except through the exception mechanism. Control cannot be transferred out of a filter block except through the use of a throw instruction or by executing the final endfilter instruction. You cannot embed a try block within a filter block. If an exception is thrown inside the filter block, it is intercepted and a value of 0 (exception_continue_search) is returned.
The following ILGenerator.Emit constructor overload can use the endfilter opcode:
public static readonly OpCode Endfinally;
|
Format | Assembly Format | Description |
---|---|---|
DC | endfinally endfault | Ends the finally or fault clause of an exception block. |
There are no stack transition behaviors for this instruction.
Endfinally and endfault signal the end of the finally or fault clause so that stack unwinding can continue until the exception handler is invoked. The endfinally or endfault instruction transfers control back to the CLI exception mechanism. The mechanism then searches for the next finally clause in the chain if the protected block was exited with a leave instruction. If the protected block was exited with an exception, the CLI will search for the next finally or fault, or enter the exception handler chosen during the first pass of exception handling.
An endfinally instruction might only appear lexically within a finally block. Unlike the endfilter instruction, there is no requirement that the block end with an endfinally instruction, and there can be as many endfinally instructions within the block as required. These same restrictions apply to the endfault instruction and the fault block.
Control cannot be transferred into a finally (or fault) block except through the exception mechanism. Control cannot be transferred out of a finally (or fault) block except through the use of a throw instruction or executing the endfinally (or endfault) instruction. In particular, you cannot "fall out" of a finally (or fault) block or to execute a OpCodes.Ret or OpCodes.Leave instruction within a finally (or fault) block.
Note that the endfault and endfinally instructions are aliases - they correspond to the same opcode.
The following ILGenerator.Emit constructor overload can use the endfinally (endfault) opcode, as well as the ILGenerator method ILGenerator.EndExceptionBlock.
public static readonly OpCode Initblk;
|
Format | Assembly Format | Description |
---|---|---|
FE 18 | initblk | Set each location in a block of memory to a given value. |
The stack transitional behavior, in sequential order, is:
The initblk instruction sets the number (unsigned int32) of bytes starting at the specified address (of type natural int, &, or *) to the initialization value (of type unsigned int8).initblk assumes that the starting address is aligned to the natural size of the machine.
The operation of the initblk instructions can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
NullReferenceException may be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the initblk opcode:
public static readonly OpCode Initobj;
|
Format | Assembly Format | Description |
---|---|---|
FE 15 < T > | initobj | Initializes a value type. |
The stack transitional behavior, in sequential order, is:
The initobj instruction initializes all the fields of the object specified by the pushed address (of type natural int, &, or *) to a null reference or a 0 of the appropriate primitive type. After this method is called, the instance is ready for the constructor method to be called. Behavior is unspecified if either the address is not a pointer to an instance of the class represented by classTok, or if classTok does not represent a value type.
Unlike OpCodes.Newobj, the constructor method is not called by initobj.Initobj is intended for initializing value types, while newobj is used to allocate and initialize objects.
The following ILGenerator.Emit constructor overloadscan use the initobj opcode:
public static readonly OpCode Isinst;
|
Format | Assembly Format | Description |
---|---|---|
75 < T > | isinst | Tests if an object reference is an instance of , returning either a null reference or an instance of that class or interface. |
The stack transitional behavior, in sequential order, is:
Class is a metadata token indicating the desired class. If the class of the object on the top of the stack implements class (if class is an interface) or is a derived class of class (if class is a regular class) then it is cast to type class and the result is pushed on the stack, exactly as though OpCodes.Castclass had been called. Otherwise, a null reference is pushed on the stack. If the object reference itself is a null reference, then isinst likewise returns a null reference.
TypeLoadException is thrown if class cannot be found. This is typically detected when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime.
The following ILGenerator.Emit constructor overload can use the isinst opcode:
public static readonly OpCode Jmp;
|
Format | Assembly Format | Description |
---|---|---|
27 < T > | jmp | Exit current method and jump to specified method. |
There are no stack transition behaviors for this instruction.
The jmp (jump) instruction transfers control to the method specified by method, which is a metadata token for a method reference. The current arguments are transferred to the destination method.
The evaluation stack must be empty when this instruction is executed. The calling convention, number and type of arguments at the destination address must match that of the current method.
The jmp instruction cannot be used to transferred control out of a try, filter, catch, or finally block.
The following ILGenerator.Emit constructor overload can use the jmp opcode:
public static readonly OpCode Ldarg;
|
Format | Assembly Format | Description |
---|---|---|
FE 09 < unsigned int16 > | ldarg | Load argument at onto stack. |
The stack transitional behavior, in sequential order, is:
The ldarg instruction pushes the argument indexed at index, where arguments are indexed from 0 onwards, onto the evaluation stack. The ldarg instruction can be used to load a value type or a primitive value onto the stack by copying it from an incoming argument. The type of the argument value is the same as the type of the argument, as specified by the current method's signature.
For procedures that take a variable-length argument list, the ldarg instruction can be used only for the initial fixed arguments, not those in the variable part of the signature (see the OpCodes.Arglist instruction for more details).
Arguments that hold an integer value smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldarg opcode:
public static readonly OpCode Ldarg_0;
|
Format | Assembly Format | Description |
---|---|---|
02 | ldarg.0 | Load argument 0 onto stack |
The stack transitional behavior, in sequential order, is:
The ldarg.0 instruction is an efficient encoding for loading the argument value at index 0.
The ldarg.0 instruction pushes the argument indexed at 0 onto the evaluation stack. The ldarg.0 instruction can be used to load a value type or a primitive value onto the stack by copying it from an incoming argument. The type of the argument value is the same as the type of the argument, as specified by the current method's signature.
Arguments that hold an integer value smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldarg.0 opcode:
public static readonly OpCode Ldarg_1;
|
Format | Assembly Format | Description |
---|---|---|
03 | ldarg.1 | Load argument 1 onto stack. |
The stack transitional behavior, in sequential order, is:
The ldarg.1 instruction is an efficient encoding for loading the argument value at index 1.
The ldarg.1 instruction pushes the argument indexed at 1 onto the evaluation stack. The ldarg.1 instruction can be used to load a value type or a primitive value onto the stack by copying it from an incoming argument. The type of the argument value is the same as the type of the argument, as specified by the current method's signature.
Arguments that hold an integer value smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldarg.1 opcode:
public static readonly OpCode Ldarg_2;
|
Format | Assembly Format | Description |
---|---|---|
04 | ldarg.2 | Load argument 2 onto stack. |
The stack transitional behavior, in sequential order, is:
The ldarg.2 instruction is an efficient encoding for loading the argument value at index 2.
The ldarg.2 instruction pushes the argument indexed at 2 onto the evaluation stack. The ldarg.2 instruction can be used to load a value type or a primitive value onto the stack by copying it from an incoming argument. The type of the argument value is the same as the type of the argument, as specified by the current method's signature.
Arguments that hold an integer value smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldarg.2 opcode:
public static readonly OpCode Ldarg_3;
|
Format | Assembly Format | Description |
---|---|---|
05 | ldarg.3 | Load argument 3 onto stack. |
The stack transitional behavior, in sequential order, is:
The ldarg.3 instruction is an efficient encoding for loading the argument value at index 3.
The ldarg.3 instruction pushes the argument indexed at 3 onto the evaluation stack. The ldarg.3 instruction can be used to load a value type or a primitive value onto the stack by copying it from an incoming argument. The type of the argument value is the same as the type of the argument, as specified by the current method's signature.
Arguments that hold an integer value smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldarg.3 opcode:
public static readonly OpCode Ldarg_S;
|
Format | Assembly Format | Description |
---|---|---|
0E < unsigned int8 > | ldarg.s | Load argument at onto stack, short form. |
The stack transitional behavior, in sequential order, is:
The ldarg.s instruction is an efficient encoding for loading arguments indexed from 4 through 255.
The ldarg.s instruction pushes the argument indexed at index, where arguments are indexed from 0 onwards, onto the evaluation stack. The ldarg.s instruction can be used to load a value type or a primitive value onto the stack by copying it from an incoming argument. The type of the argument value is the same as the type of the argument, as specified by the current method's signature.
For procedures that take a variable-length argument list, the ldarg.s instruction can be used only for the initial fixed arguments, not those in the variable part of the signature (see the OpCodes.Arglist instruction for more details).
Arguments that hold an integer value smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldarg.s opcode:
public static readonly OpCode Ldarga;
|
Format | Assembly Format | Description |
---|---|---|
FE 0A < unsigned int16 > | ldarga | Fetch the address of argument indexed by . |
The stack transitional behavior, in sequential order, is:
The ldarga instruction fetches the address (of type *) of the argument indexed by index, where arguments are indexed from 0 onwards. The address addr is always aligned to a natural boundary on the target machine.
For procedures that take a variable-length argument list, the ldarga instruction can be used only for the initial fixed arguments, not those in the variable part of the signature.
ldarga is used for by-ref parameter passing. For other cases, OpCodes.Ldarg and OpCodes.Starg should be used.
The following ILGenerator.Emit constructor overload can use the ldarga opcode:
public static readonly OpCode Ldarga_S;
|
Format | Assembly Format | Description |
---|---|---|
0F < unsigned int8 > | ldarga.s | Fetch the address of argument indexed by short form. |
The stack transitional behavior, in sequential order, is:
ldarga.s (the short form of ldarga) should be used for argument numbers 0 through 255, and is a more efficient encoding.
The ldarga.s instruction fetches the address (of type *) of the argument indexed by index, where arguments are indexed from 0 onwards. The address addr is always aligned to a natural boundary on the target machine.
For procedures that take a variable-length argument list, the ldarga.s instruction can be used only for the initial fixed arguments, not those in the variable part of the signature.
ldarga.s is used for by-ref parameter passing. For other cases, OpCodes.Ldarg_S and OpCodes.Starg_S should be used.
The following ILGenerator.Emit constructor overload can use the ldarga.s opcode:
public static readonly OpCode Ldc_I4;
|
Format | Assembly Format | Description |
---|---|---|
20 < int32 > | ldc.i4 | Pushes the value onto the stack. |
The stack transitional behavior, in sequential order, is:
Note that there are special short (and hence more efficient) encodings for the integers -128 through 127, and especially short encodings for -1 through 8. All short encodings push 4 byte integers on the stack. Longer encodings are used for 8 byte integers and 4 and 8 byte floating-point numbers, as well as 4-byte values that do not fit in the short forms. There are three ways to push an 8 byte integer constant onto the stack
1. Use the OpCodes.Ldc_I8 instruction for constants that must be expressed in more than 32 bits.
2. Use the OpCodes.Ldc_I4 instruction followed by a OpCodes.Conv_I8 for constants that require 9 to 32 bits.
3. Use a short form instruction followed by a OpCodes.Conv_I8 for constants that can be expressed in 8 or fewer bits.
The following ILGenerator.Emit constructor overload can use the ldc.i4 opcode:
public static readonly OpCode Ldc_I4_0;
|
Format | Assembly Format | Description |
---|---|---|
16 | ldc.i4.0 | Pushes 0 onto the stack. |
The stack transitional behavior, in sequential order, is:
This is a special short encoding for the push of the integer value 0. All special short encodings push 4 byte integers on the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.0 opcode:
public static readonly OpCode Ldc_I4_1;
|
Format | Assembly Format | Description |
---|---|---|
17 | ldc.i4.1 | Pushes 1 onto the stack. |
The stack transitional behavior, in sequential order, is:
This is a special short encoding for the push of the integer value 0. All special short encodings push 4 byte integers on the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.1 opcode:
public static readonly OpCode Ldc_I4_2;
|
Format | Assembly Format | Description |
---|---|---|
18 | ldc.i4.2 | Pushes 2 onto the stack. |
The stack transitional behavior, in sequential order, is:
This is a special short encoding for the push of the integer value 0. All special short encodings push 4 byte integers on the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.2 opcode:
public static readonly OpCode Ldc_I4_3;
|
Format | Assembly Format | Description |
---|---|---|
19 | ldc.i4.3 | Pushes 3 onto the stack. |
The stack transitional behavior, in sequential order, is:
This is a special short encoding for the push of the integer value 0. All special short encodings push 4 byte integers on the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.3 opcode:
public static readonly OpCode Ldc_I4_4;
|
Format | Assembly Format | Description |
---|---|---|
1A | ldc.i4.4 | Pushes 4 onto the stack. |
The stack transitional behavior, in sequential order, is:
This is a special short encoding for the push of the integer value 0. All special short encodings push 4 byte integers on the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.4 opcode:
public static readonly OpCode Ldc_I4_5;
|
Format | Assembly Format | Description |
---|---|---|
1B | ldc.i4.5 | Pushes 5 onto the stack. |
The stack transitional behavior, in sequential order, is:
This is a special short encoding for the push of the integer value 0. All special short encodings push 4 byte integers on the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.5 opcode:
public static readonly OpCode Ldc_I4_6;
|
Format | Assembly Format | Description |
---|---|---|
1C | ldc.i4.6 | Pushes 6 onto the stack. |
The stack transitional behavior, in sequential order, is:
This is a special short encoding for the push of the integer value 0. All special short encodings push 4 byte integers on the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.6 opcode:
public static readonly OpCode Ldc_I4_7;
|
Format | Assembly Format | Description |
---|---|---|
1D | ldc.i4.7 | Pushes 7 onto the stack. |
The stack transitional behavior, in sequential order, is:
This is a special short encoding for the push of the integer value 0. All special short encodings push 4 byte integers on the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.7 opcode:
public static readonly OpCode Ldc_I4_8;
|
Format | Assembly Format | Description |
---|---|---|
1E | ldc.i4.8 | Pushes 8 onto the stack. |
The stack transitional behavior, in sequential order, is:
This is a special short encoding for the push of the integer value 0. All special short encodings push 4 byte integers on the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.8 opcode:
public static readonly OpCode Ldc_I4_M1;
|
Format | Assembly Format | Description |
---|---|---|
15 | ldc.i4.m1 | Pushes -1 onto the stack. |
The stack transitional behavior, in sequential order, is:
This is a special short encoding for the push of the integer value 0. All special short encodings push 4 byte integers on the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.m1 opcode:
public static readonly OpCode Ldc_I4_S;
|
Format | Assembly Format | Description |
---|---|---|
1F < int8 > | ldc.i4.s | Pushes onto the stack as int32 , short form. |
The stack transitional behavior, in sequential order, is:
ldc.i4.s is a more efficient encoding for pushing the integers from -127 to 128 onto the evaluation stack.
The following ILGenerator.Emit constructor overload can use the ldc.i4.s opcode:
public static readonly OpCode Ldc_I8;
|
Format | Assembly Format | Description |
---|---|---|
21 < int64 > | ldc.i8 | Pushes onto the stack as int64 . |
The stack transitional behavior, in sequential order, is:
This encoding pushes an int64 value onto the stack.
The following ILGenerator.Emit constructor overload can use the ldc.i8 opcode:
public static readonly OpCode Ldc_R4;
|
Format | Assembly Format | Description |
---|---|---|
22 < float32 > | ldc.r4 | Pushes onto the stack as F . |
The stack transitional behavior, in sequential order, is:
This encoding pushes a float32 value onto the stack.
The following ILGenerator.Emit constructor overload can use the ldc.r4 opcode:
public static readonly OpCode Ldc_R8;
|
Format | Assembly Format | Description |
---|---|---|
23 < float64 > | ldc.r8 | Pushes onto the stack as F . |
The stack transitional behavior, in sequential order, is:
This encoding pushes a float64 value onto the stack.
The following ILGenerator.Emit constructor overload can use the ldc.r8 opcode:
public static readonly OpCode Ldelem_I;
|
Format | Assembly Format | Description |
---|---|---|
97 | ldelem.i | Loads the element with type natural int at onto the top of the stack as a natural int . |
The stack transitional behavior, in sequential order, is:
The ldelem.i instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.i is natural int.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
The following ILGenerator.Emit constructor overload can use the ldelem.i opcode:
public static readonly OpCode Ldelem_I1;
|
Format | Assembly Format | Description |
---|---|---|
90 | ldelem.i1 | Loads the element with type int8 at onto the top of the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldelem.i1 instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.i1 is int8.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
The following ILGenerator.Emit constructor overload can use the ldelem.i1 opcode:
public static readonly OpCode Ldelem_I2;
|
Format | Assembly Format | Description |
---|---|---|
92 | ldelem.i2 | Loads the element with type int16 at onto the top of the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldelem.i2 instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.i2 is int16.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.The following ILGenerator.Emit constructor overload can use the ldelem.i2 opcode:
public static readonly OpCode Ldelem_I4;
|
Format | Assembly Format | Description |
---|---|---|
94 | ldelem.i4 | Loads the element with type int32 at onto the top of the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldelem.i4 instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.i4 is int32.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.The following ILGenerator.Emit constructor overload can use the ldelem.i4 opcode:
public static readonly OpCode Ldelem_I8;
|
Format | Assembly Format | Description |
---|---|---|
96 | ldelem.i8 | Loads the element with type int64 at onto the top of the stack as an int64 . |
The stack transitional behavior, in sequential order, is:
The ldelem.i8 instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.i8 is int64.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.The following ILGenerator.Emit constructor overload can use the ldelem.i8 opcode:
public static readonly OpCode Ldelem_R4;
|
Format | Assembly Format | Description |
---|---|---|
98 | ldelem.r4 | Loads the element with type float32 at onto the top of the stack as a type F . |
The stack transitional behavior, in sequential order, is:
The ldelem.r4 instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.r4 is float32.
Floating-point values are converted to type F when loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.The following ILGenerator.Emit constructor overload can use the ldelem.r4 opcode:
public static readonly OpCode Ldelem_R8;
|
Format | Assembly Format | Description |
---|---|---|
99 | ldelem.r8 | Loads the element with type float64 at onto the top of the stack as type F . |
The stack transitional behavior, in sequential order, is:
The ldelem.r8 instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.r8 is float64.
Floating-point values are converted to type F when loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.The following ILGenerator.Emit constructor overload can use the ldelem.r8 opcode:
public static readonly OpCode Ldelem_Ref;
|
Format | Assembly Format | Description |
---|---|---|
9A | ldelem.ref | Loads the element with an object reference at onto the top of the stack as type O . |
The stack transitional behavior, in sequential order, is:
The ldelem.ref instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.ref is type O (object reference).
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.The following ILGenerator.Emit constructor overload can use the ldelem.ref opcode:
public static readonly OpCode Ldelem_U1;
|
Format | Assembly Format | Description |
---|---|---|
91 | ldelem.u1 | Loads the element with type unsigned int8 at onto the top of the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldelem.u1 instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.u1 is int8.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.The following ILGenerator.Emit constructor overload can use the ldelem.u1 opcode:
public static readonly OpCode Ldelem_U2;
|
Format | Assembly Format | Description |
---|---|---|
93 | ldelem.u2 | Loads the element with type unsigned int16 at index onto the top of the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldelem.u2 instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.u2 is int16.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.The following ILGenerator.Emit constructor overload can use the ldelem.u2 opcode:
public static readonly OpCode Ldelem_U4;
|
Format | Assembly Format | Description |
---|---|---|
94 | ldelem.u4 | Loads the element with type unsigned int32 at index onto the top of the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldelem.u4 instruction loads the value of the element with index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O.
The return value for ldelem.u4 is int32.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.The following ILGenerator.Emit constructor overload can use the ldelem.u4 opcode:
public static readonly OpCode Ldelema;
|
Format | Assembly Format | Description |
---|---|---|
8F < T > | ldelema | Loads the address of the array element at onto the top of the evaluation stack as type & (managed pointer). |
The stack transitional behavior, in sequential order, is:
The ldelema is used to retrieve the address of an object at a particular index in an array of objects (of type class). The ldelema instruction loads the address of the value at index index (type natural int) in the zero-based one-dimensional array array and places it on the top of the stack. Arrays are objects and hence represented by a value of type O. The value must be of type class passed with the instruction.
The return value for ldelema is a managed pointer (type &).
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack.
NullReferenceException is thrown if array is a null reference.
ArrayTypeMismatchException is thrown if if array does not hold elements of the required type.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
The following ILGenerator.Emit constructor overload can use the ldelema opcode:
public static readonly OpCode Ldfld;
|
Format | Assembly Format | Description |
---|---|---|
7B < T > | ldfld | Pushes the value of a field in a specified object onto the stack. |
The stack transitional behavior, in sequential order, is:
The ldfld instruction pushes the value of a field located in an object onto the stack. The object must be on the stack as an object reference (type O), a managed pointer (type &), an unmanaged pointer (type natural int), a transient pointer (type *), or an instance of a value type. The use of an unmanaged pointer is not permitted in verifiable code. The object's field is specified by a metadata token that must refer to a field member. The return type is the same as the one associated with the field. The field may be either an instance field (in which case the object must not be a null reference) or a static field.
The ldfld instruction can be preceded by either or both of the OpCodes.Unaligned and OpCodes.Volatile prefixes.
NullReferenceException is thrown if the object is null and the field is not static.
MissingFieldException is thrown if the specified field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time.
The following ILGenerator.Emit constructor overload can use the ldfld opcode:
public static readonly OpCode Ldflda;
|
Format | Assembly Format | Description |
---|---|---|
7C < T > | ldflda | Pushes the address of in a specified object onto the stack. |
The stack transitional behavior, in sequential order, is:
The ldflda instruction pushes the address of a field located in an object onto the stack. The object must be on the stack as an object reference (type O), a managed pointer (type &), an unmanaged pointer (type natural int), a transient pointer (type *), or an instance of a value type. The use of an unmanaged pointer is not permitted in verifiable code. The object's field is specified by a metadata token that must refer to a field member.
The value returned by ldflda is a managed pointer (type &) unless the object is pushed onto the stack as an unmanaged pointer, in which case the return address is also an unmanaged pointer (type natural int).
The ldflda instruction can be preceded by either or both of the OpCodes.Unaligned and OpCodes.Volatile prefixes.
InvalidOperationException is thrown if the object is not within the application domain from which it is being accessed. The address of a field that is not inside the accessing application domain cannot be loaded.
NullReferenceException is thrown if the object is null and the field is not static.
MissingFieldException is thrown if the specified field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time.
The following ILGenerator.Emit constructor overload can use the ldflda opcode:
public static readonly OpCode Ldftn;
|
Format | Assembly Format | Description |
---|---|---|
FE 06 < T > | ldftn | Pushes a pointer to a method referenced by on the stack. |
The stack transitional behavior, in sequential order, is:
The specific method (method) can be called using the OpCodes.Calli instruction if it references a managed method (or a stub that transitions from managed to unmanaged code).
The value returned points to native code using the calling convention specified by the method metadata token. Thus, a method pointer can be easily passed to unmanaged native code (specifically, as a callback routine).
The following ILGenerator.Emit constructor overload can use the ldftn opcode:
public static readonly OpCode Ldind_I;
|
Format | Assembly Format | Description |
---|---|---|
4D | ldind.i | Loads the natural int value at address onto the stack as a natural int . |
The stack transitional behavior, in sequential order, is:
The ldind.i instruction indirectly loads a natural int value from the specified address (of type natural int, &, or *) onto the stack as a natural int.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.i opcode:
public static readonly OpCode Ldind_I1;
|
Format | Assembly Format | Description |
---|---|---|
46 | ldind.i1 | Loads the int8 value at address onto the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldind.i1 instruction indirectly loads an int8 value from the specified address (of type natural int, &, or *) onto the stack as an int32.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.i1 opcode:
public static readonly OpCode Ldind_I2;
|
Format | Assembly Format | Description |
---|---|---|
48 | ldind.i2 | Loads the int16 value at address onto the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldind.i2 instruction indirectly loads an int16 value from the specified address (of type natural int, &, or *) onto the stack as an int32.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.i2 opcode:
public static readonly OpCode Ldind_I4;
|
Format | Assembly Format | Description |
---|---|---|
4A | ldind.i4 | Loads the int32 value at address onto the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldind.i4 instruction indirectly loads an int32 value from the specified address (of type natural int, &, or *) onto the stack as a int32.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.i4 opcode:
public static readonly OpCode Ldind_I8;
|
Format | Assembly Format | Description |
---|---|---|
4C | ldind.i8 | Loads the int64 value at address onto the stack as an int64 . |
The stack transitional behavior, in sequential order, is:
The ldind.i8 instruction indirectly loads an int64 value from the specified address (of type natural int, &, or *) onto the stack as an int64.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.i8 opcode:
public static readonly OpCode Ldind_R4;
|
Format | Assembly Format | Description |
---|---|---|
4E | ldind.r4 | Loads the float32 value at address onto the stack as a type F . |
The stack transitional behavior, in sequential order, is:
The ldind.r4 instruction indirectly loads a float32 value from the specified address (of type natural int, &, or *) onto the stack as a type F.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.r4 opcode:
public static readonly OpCode Ldind_R8;
|
Format | Assembly Format | Description |
---|---|---|
4F | ldind.r8 | Loads the float64 value at address onto the stack as a type F . |
The stack transitional behavior, in sequential order, is:
The ldind.r8 instruction indirectly loads a float64 value from the specified address (of type natural int, &, or *) onto the stack as a float64.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.r8 opcode:
public static readonly OpCode Ldind_Ref;
|
Format | Assembly Format | Description |
---|---|---|
50 | ldind.ref | Loads the object reference at address onto the stack as a type O |
The stack transitional behavior, in sequential order, is:
The ldind.ref instruction indirectly loads the object reference the specified address (of type natural int, &, or *) onto the stack as type O.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.ref opcode:
public static readonly OpCode Ldind_U1;
|
Format | Assembly Format | Description |
---|---|---|
47 | ldind.u1 | Loads the u nsigned int8 value at address onto the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldind.u1 instruction indirectly loads an unsigned int8 value from the specified address (of type natural int, &, or *) onto the stack as an int32.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.u1 opcode:
public static readonly OpCode Ldind_U2;
|
Format | Assembly Format | Description |
---|---|---|
49 | ldind.u2 | Loads the unsigned int16 value at address onto the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldind.u2 instruction indirectly loads an unsigned int16 value from the specified address (of type natural int, &, or *) onto the stack as an int32.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.u2 opcode:
public static readonly OpCode Ldind_U4;
|
Format | Assembly Format | Description |
---|---|---|
4B | ldind.u4 | Loads the unsigned int32 value at address onto the stack as an int32 . |
The stack transitional behavior, in sequential order, is:
The ldind.u4 instruction indirectly loads an unsigned int32 value from the specified address (of type natural int, &, or *) onto the stack as an int32.
All of the ldind instructions are shortcuts for a OpCodes.Ldobj instruction that specifies the corresponding built-in value class.
Note that integer values of less than 4 bytes are extended to int32 (not natural int) when they are loaded onto the evaluation stack. Floating-point values are converted to F type when loaded onto the evaluation stack.
Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the ldind instructions are used in a manner consistent with the type of the pointer.
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 OpCodes.Unaligned prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, OpCodes.Ldloca and OpCodes.Ldarga) are safely aligned. 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.
NullReferenceException can be thrown if an invalid address is detected.
The following ILGenerator.Emit constructor overload can use the ldind.u4 opcode:
public static readonly OpCode Ldlen;
|
Format | Assembly Format | Description |
---|---|---|
8E | ldlen | Pushes the length (of type natural unsigned int ) of an array on the stack. |
The stack transitional behavior, in sequential order, is:
Arrays are objects and hence represented by a value of type O. The length is returned as a natural unsigned int.
NullReferenceException is thrown if the array reference is a null reference.
The following ILGenerator.Emit constructor overload can use the ldlen opcode:
public static readonly OpCode Ldloc;
|
Format | Assembly Format | Description |
---|---|---|
FE 06 < unsigned int16 > | ldloc | Loads the local variable at index onto stack. |
The stack transitional behavior, in sequential order, is:
The ldloc instruction pushes the contents of the local variable number at the passed index onto the evaluation stack, where the local variables are numbered 0 onwards. Local variables are initialized to 0 before entering the method only if the initialize flag on the method is true. There are 65,535 (2^16-1) local variables possible (0-65,534). Index 65,535 is not valid since likely implementations will use a 2-byte integer to track both a local's index, along with the total number of locals for a given method. If an index of 65535 had been made valid, it would require a wider integer to track the number of locals in such a method.
The ldloc.0, ldloc.1, ldloc.2, and ldloc.3 instructions provide an efficient encoding for accessing the first four local variables.
The type of the value is the same as the type of the local variable, which is specified in the method header. See Partition I. Local variables that are smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldloc opcode:
public static readonly OpCode Ldloc_0;
|
Format | Assembly Format | Description |
---|---|---|
06 | ldloc.0 | Loads the local variable at index 0 onto the evaluation stack. |
The stack transitional behavior, in sequential order, is:
ldloc.0 is an especially efficient encoding for OpCodes.Ldloc, allowing access to the local variable at index 0.
The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldloc.0 opcode:
public static readonly OpCode Ldloc_1;
|
Format | Assembly Format | Description |
---|---|---|
07 | ldloc.1 | Loads the local variable at index 1 onto the evaluation stack. |
The stack transitional behavior, in sequential order, is:
ldloc.1 is an especially efficient encoding for OpCodes.Ldloc, allowing access to the local variable at index 1.
The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldloc.1 opcode:
public static readonly OpCode Ldloc_2;
|
Format | Assembly Format | Description |
---|---|---|
08 | ldloc.2 | Loads the local variable at index 2 onto the evaluation stack. |
The stack transitional behavior, in sequential order, is:
ldloc.2 is an especially efficient encoding for OpCodes.Ldloc, allowing access to the local variable at index 2.
The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldloc.2 opcode:
public static readonly OpCode Ldloc_3;
|
Format | Assembly Format | Description |
---|---|---|
09 | ldloc.3 | Loads the local variable at index 3 onto the evaluation stack. |
The stack transitional behavior, in sequential order, is:
ldloc.3 is an especially efficient encoding for OpCodes.Ldloc, allowing access to the local variable at index 3.
The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldloc.3 opcode:
public static readonly OpCode Ldloc_S;
|
Format | Assembly Format | Description |
---|---|---|
11 < unsigned int8 > | ldloc.s | Loads the local variable at index onto stack, short form. |
The stack transitional behavior, in sequential order, is:
The ldloc.s instruction pushes the contents of the local variable number at the passed index onto the evaluation stack, where the local variables are numbered 0 onwards. Local variables are initialized to 0 before entering the method if the initialize flag on the method is true. There are 256 (2^8) local variables possible (0-255) in the short form, which is a more efficient encoding than ldloc.
The type of the value is the same as the type of the local variable, which is specified in the method header. See Partition I. Local variables that are smaller than 4 bytes long are expanded to type int32 when they are loaded onto the stack. Floating-point values are expanded to their native size (type F).
The following ILGenerator.Emit constructor overload can use the ldloc.s opcode:
public static readonly OpCode Ldloca;
|
Format | Assembly Format | Description |
---|---|---|
FE OD < unsigned int16 > | ldloca | Loads the address of the local variable at onto the evaluation stack. |
The stack transitional behavior, in sequential order, is:
The ldloca instruction pushes the address of the local variable number at the passed index onto the stack, where local variables are numbered 0 onwards. The value pushed on the stack is already aligned correctly for use with instructions like OpCodes.Ldind_I and OpCodes.Stind_I. The result is a transient pointer (type *).
The following ILGenerator.Emit constructor overload can use the ldloca opcode:
public static readonly OpCode Ldloca_S;
|
Format | Assembly Format | Description |
---|---|---|
12 < unsigned int8 > | ldloca.s | Loads the address of the local variable at onto the evaluation stack, short form. |
The stack transitional behavior, in sequential order, is:
The ldloca.s instruction pushes the address of the local variable number at the passed index onto the stack, where local variables are numbered 0 onwards. The value pushed on the stack is already aligned correctly for use with instructions like OpCodes.Ldind_I and OpCodes.Stind_I. The result is a transient pointer (type *).
The ldloca.s instruction provides an efficient encoding for use with the local variables 0 through 255.
The following ILGenerator.Emit constructor overload can use the ldloca.s opcode:
public static readonly OpCode Ldnull;
|
Format | Assembly Format | Description |
---|---|---|
14 | ldnull | push a null reference onto the stack |
The stack transitional behavior, in sequential order, is:
ldnull pushes a null reference (type O) on the stack. This is used to initialize locations before they are populated with data, or when they become deprecated.
ldnull provides a null reference that is size-independent.
The following ILGenerator.Emit constructor overload can use the ldnull opcode:
public static readonly OpCode Ldobj;
|
Format | Assembly Format | Description |
---|---|---|
71 < T > | ldobj | Copy instance of value type to the stack. |
The stack transitional behavior, in sequential order, is:
The ldobj instruction is used to pass a value type as a parameter.
The ldobj instruction copies the value pointed to by addrOfValObj (of type &, *, or natural int) to the top of the stack. The number of bytes copied depends on the size of the class (as specified by the class parameter). The class parameter is a metadata token representing the value type.
The operation of the ldobj instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
TypeLoadException is thrown if class cannot be found. This is typically detected when the Microsoft Intermediate Language (MSIL) instruction is converted to native code rather than at runtime.
The following ILGenerator.Emit constructor overload can use the ldobj opcode:
public static readonly OpCode Ldsfld;
|
Format | Assembly Format | Description |
---|---|---|
7E < T > | ldsfld | Push the value of on the stack. |
The stack transitional behavior, in sequential order, is:
The ldsfld instruction pushes the value of a static (shared among all instances of a class) field on the stack. The return type is that associated with the passed metadata token field.
The ldsfld instruction can have a OpCodes.Volatile prefix.
The following ILGenerator.Emit constructor overload can use the ldsfld opcode:
public static readonly OpCode Ldsflda;
|
Format | Assembly Format | Description |
---|---|---|
7F < T > | ldsflda | Push the address of on the stack |
The stack transitional behavior, in sequential order, is:
The ldsflda instruction pushes the address of a static (shared among all instances of a class) field on the stack. The address may be represented as a transient pointer (type *) if the metadata token field refers to a type whose memory is managed. Otherwise, it corresponds to an unmanaged pointer (type natural int). Note that field may be a static global with an assigned relative virtual address (the offset of the field from the base address at which its containing PE file is loaded into memory) where the memory is unmanaged.
The ldsflda instruction can have a OpCodes.Volatile prefix.
MissingFieldException is thrown if field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at runtime.
The following ILGenerator.Emit constructor overload can use the ldsflda opcode:
public static readonly OpCode Ldstr;
|
Format | Assembly Format | Description |
---|---|---|
72 < T > | ldstr | Pushes a string object for the metadata string token . |
The stack transitional behavior, in sequential order, is:
The ldstr instruction pushes an object reference (type O) to a new string object representing the specific string literal stored in the metadata. The ldstr instruction allocates the requisite amount of memory and performs any format conversion required to convert the string literal from the form used in the file to the string format required at runtime.
The Common Language Infrastructure (CLI) guarantees that the result of two ldstr instructions referring to two metadata tokens that have the same sequence of characters return precisely the same string object (a process known as "string interning").
The following ILGenerator.Emit constructor overload can use the ldstr opcode:
public static readonly OpCode Ldtoken;
|
Format | Assembly Format | Description |
---|---|---|
D0 < T > | ldtoken | Converts a metadata token to its runtime representation. |
The stack transitional behavior, in sequential order, is:
The ldtoken instruction pushes a RuntimeHandle for the specified metadata token. A RuntimeHandle can be a fieldref/fielddef, a methodref/methoddef, or a typeref/typedef.
The value pushed on the stack can be used in calls to Reflection methods in the system class library.
For information on runtime handles, see the following classes: RuntimeFieldHandle, RuntimeTypeHandle, and RuntimeMethodHandle.
The following ILGenerator.Emit constructor overloads can use the ldtoken opcode:
public static readonly OpCode Ldvirtftn;
|
Format | Assembly Format | Description |
---|---|---|
FE 07 < T > | ldvirtftn | Pushes the pointer to an object's virtual method on the stack. |
The stack transitional behavior, in sequential order, is:
The resulting unmanaged pointer pushed onto the stack by the ldvirtftn instruction can be called using the OpCodes.Calli instruction if it references a managed method (or a stub that transitions from managed to unmanaged code).
The unmanaged pointer points to native code using the calling convention specified by in the metadata token method. As a result, the method pointer can be passed to unmanaged native code (for example, as a callback routine) if that routine expects the corresponding calling convention.
The following ILGenerator.Emit constructor overload can use the ldvirtftn opcode:
public static readonly OpCode Leave;
|
Format | Assembly Format | Description |
---|---|---|
DD < int32 > | leave | Exits a protected region of code. |
There is no stack transition behavior specified for this instruction.
The leave instruction unconditionally transfers control to the specific target instruction, represented as a 4-byte signed offset from the beginning of the instruction following the current instruction.
The leave instruction is similar to the br instruction, but it can be used to exit a try, filter, or catch block whereas the ordinary branch instructions can only be used in such a block to transfer control within it. The leave instruction empties the evaluation stack and ensures that the appropriate surrounding finally blocks are executed.
You cannot use a leave instruction to exit a finally block. To ease code generation for exception handlers it is valid from within a catch block to use a leave instruction to transfer control to any instruction within the associated try block.
If an instruction has one or more prefix codes, control can only be transferred to the first of these prefixes.
The following ILGenerator.Emit constructor overloads can use the leave opcode:
public static readonly OpCode Leave_S;
|
Format | Assembly Format | Description |
---|---|---|
DE < int8 > | leave.s | Exit a protected region of code, short form. |
There is no stack transition behavior specified for this instruction.
The leave.s instruction unconditionally transfers control to the passed target instruction, represented as a 1-byte signed offset from the beginning of the instruction following the current instruction.
The leave.s instruction is similar to the br instruction, but it can be used to exit a try, filter, or catch block whereas the ordinary branch instructions can only be used in such a block to transfer control within it. The leave.s instruction empties the evaluation stack and ensures that the appropriate surrounding finally blocks are executed.
You cannot use a leave.s instruction to exit a finally block. To ease code generation for exception handlers it is valid from within a catch block to use a leave.s instruction to transfer control to any instruction within the associated try block.
If an instruction has one or more prefix codes, control can only be transferred to the first of these prefixes.
The following ILGenerator.Emit constructor overload can use the leave.s opcode:
public static readonly OpCode Localloc;
|
Format | Assembly Format | Description |
---|---|---|
FE 0F | localloc | Allocate space from the local heap. |
The stack transitional behavior, in sequential order, is:
The localloc instruction allocates size (type natural unsigned int) bytes from the local dynamic memory pool and returns the address (a transient pointer, type *) of the first allocated byte. The block of memory returned is initialized to 0 only if the initialize flag on the method is true. When the current method executes a OpCodes.Ret, the local memory pool is made available for reuse.
The resulting address is aligned so that any primitive data type can be stored there using the stind instructions (such as OpCodes.Stind_I4) and loaded using the ldind instructions (such as OpCodes.Ldind_I4).
The localloc instruction cannot occur within a filter, catch, finally, or fault block.
StackOverflowException is thrown if there is insufficient memory to service the request.
The following ILGenerator.Emit constructor overload can use the localloc opcode:
public static readonly OpCode Mkrefany;
|
Format | Assembly Format | Description |
---|---|---|
C6 < T > | mkrefany | Pushes a typed reference of type onto the stack. |
The stack transitional behavior, in sequential order, is:
The mkrefany instruction supports the passing of dynamically typed references. The pointer must be of type &, *, or natural int, and hold the valid address of a piece of data.Class is the class token describing the type of the data referenced by the pointer.Mkrefany pushes a typed reference on the stack, providing an opaque descriptor of the pointer and the type class.
The only valid operation permitted upon a typed reference is to pass it to a method that requires a typed reference as a parameter. The callee can then use the OpCodes.Refanytype and OpCodes.Refanyval instructions to retrieve the type (class) and the address respectively.
TypeLoadException is thrown if class cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime.
The following ILGenerator.Emit constructor overload can use the mkrefany opcode:
public static readonly OpCode Mul;
|
Format | Assembly Format | Description |
---|---|---|
5A | mul | Multiplies two values on the stack. |
The stack transitional behavior, in sequential order, is:
The mul instruction multiplies value1 by value2 and pushes the result on the stack. Integer operations silently truncate the upper bits on overflow.
See OpCodes.Mul_Ovf for an integer-specific multiply operation with overflow handling.
For floating-point types, 0 * infinity = NaN.
The following ILGenerator.Emit constructor overload can use the mul opcode:
public static readonly OpCode Mul_Ovf;
|
Format | Assembly Format | Description |
---|---|---|
D8 | mul.ovf | Multiplies two integer values on the stack with an overflow check. |
The stack transitional behavior, in sequential order, is:
The mul.ovf instruction multiplies integer value1 by integer value2 and pushes the result on the stack. An exception is thrown if the result will not fit in the result type.
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the mul.ovf opcode:
public static readonly OpCode Mul_Ovf_Un;
|
Format | Assembly Format | Description |
---|---|---|
D9 | mul.ovf.un | Multiplies two unsigned values on the stack with an overflow check. |
The stack transitional behavior, in sequential order, is:
The mul.ovf.un instruction multiplies unsigned integer value1 by unsigned integer value2 and pushes the result on the stack. An exception is thrown if the result will not fit in the result type.
OverflowException is thrown if the result can not be represented in the result type.
The following ILGenerator.Emit constructor overload can use the mul.ovf.un opcode:
public static readonly OpCode Neg;
|
Format | Assembly Format | Description |
---|---|---|
65 | neg | Negates the value currently on top of the stack. |
The stack transitional behavior, in sequential order, is:
The neg instruction negates value and pushes the result on top of the stack. The return type is the same as the operand type.
Negation of integral values is standard two's complement negation. In particular, negating the most negative number (which does not have a positive counterpart) yields the most negative number. To detect this overflow use the OpCodes.Sub_Ovf instruction instead (that is, subtract from 0).
Negating a floating-point number cannot overflow, and negating NaN returns NaN.
The following ILGenerator.Emit constructor overload can use the neg opcode:
public static readonly OpCode Newarr;
|
Format | Assembly Format | Description |
---|---|---|
8D < T > | newarr | Createa a new array with elements of type |
The stack transitional behavior, in sequential order, is:
The newarr instruction pushes an object reference (type O) to a new zero-based, one-dimensional array whose elements are of type etype (a metadata token describing the type). The number of elements in the new array should be specified as a natural int. Valid array indexes range from zero to the maximum number of elements minus one.
The elements of an array can be any type, including value types.
Zero-based, one-dimensional arrays of numbers are created using a metadata token referencing the appropriate value type ( Int32, and so on). Elements of the array are initialized to 0 of the appropriate type.
Nonzero-based one-dimensional arrays and multidimensional arrays are created using OpCodes.Newobj rather than newarr. More commonly, they are created using the methods of the Array class in the .NET Framework.
OutOfMemoryException is thrown if there is insufficient memory to satisfy the request.
OverflowException is thrown if numElems is less than 0.
The following ILGenerator.Emit constructor overload can use the newarr opcode:
public static readonly OpCode Newobj;
|
Format | Assembly Format | Description |
---|---|---|
73 < T > | newobj | Allocates an uninitialized object or value type and calls the constructor method |
The stack transitional behavior, in sequential order, is:
The newobj instruction creates a new object or a new instance of a value type.Ctor is a metadata token (a methodref or methoddef that must be marked as a constructor) that indicates the name, class and signature of the constructor to call.
The newobj instruction allocates a new instance of the class associated with ctor and initializes all the fields in the new instance to 0 (of the proper type) or null references as appropriate. It then calls the constructor ctor with the given arguments along with the newly created instance. After the constructor has been called, the now initialized object reference (type O) is pushed on the stack.
From the constructor's point of view, the uninitialized object is argument 0 and the other arguments passed to newobj follow in order.
All zero-based, one-dimensional arrays are created using OpCodes.Newarr, not newobj. On the other hand, all other arrays (more than one dimension, or one-dimensional but not zero-based) are created using newobj.
Value types are not usually created using newobj. They are usually allocated either as arguments or local variables, using newarr (for zero-based, one-dimensional arrays), or as fields of objects. Once allocated, they are initialized using OpCodes.Initobj. However, the newobj instruction can be used to create a new instance of a value type on the stack, that can then be passed as an argument, stored in a local, and so on.
OutOfMemoryException is thrown if there is insufficient memory to satisfy the request.
MissingMethodException is thrown if a constructor method ctor with the indicated name, class and signature could not be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code, rather than at runtime.
The following ILGenerator.Emit constructor overload can use the newobj opcode:
public static readonly OpCode Nop;
|
Format | Assembly Format | Description |
---|---|---|
00 | nop | Performs an operation without behavior. |
There is no stack transitional behavior defined for this instruction.
The nop operation does nothing. It is intended to fill in space if bytecodes are patched.
The following ILGenerator.Emit constructor overload can use the nop opcode:
public static readonly OpCode Not;
|
Format | Assembly Format | Description |
---|---|---|
66 | not | Computes the bitwise complement of a value. |
The stack transitional behavior, in sequential order, is:
The not instruction computes the bitwise complement of an integer value and pushes the result onto the stack. The return type is the same as the operand type.
The following ILGenerator.Emit constructor overload can use the not opcode:
public static readonly OpCode Or;
|
Format | Assembly Format | Description |
---|---|---|
60 | or | Computes the bitwise OR of two integer values, returns an integer. |
The stack transitional behavior, in sequential order, is:
The or instruction computes the bitwise OR of two values atop the stack, pushing the result onto the stack.
Or is an integer-specific operation.
The following ILGenerator.Emit constructor overload can use the or opcode:
public static readonly OpCode Pop;
|
Format | Assembly Format | Description |
---|---|---|
26 | pop | Pops the top value from the stack. |
The stack transitional behavior, in sequential order, is:
The pop instruction removes the top element from the stack.
The following ILGenerator.Emit constructor overload can use the pop opcode:
public static readonly OpCode Prefix1;
|
Format | Assembly Format | Description |
---|---|---|
prefix1 |
public static readonly OpCode Prefix2;
|
Format | Assembly Format | Description |
---|---|---|
prefix2 |
public static readonly OpCode Prefix3;
|
Format | Assembly Format | Description |
---|---|---|
prefix3 |
public static readonly OpCode Prefix4;
|
Format | Assembly Format | Description |
---|---|---|
prefix4 |
public static readonly OpCode Prefix5;
|
Format | Assembly Format | Description |
---|---|---|
prefix5 |
public static readonly OpCode Prefix6;
|
Format | Assembly Format | Description |
---|---|---|
prefix6 |
public static readonly OpCode Prefix7;
|
Format | Assembly Format | Description |
---|---|---|
prefix7 |
public static readonly OpCode Prefixref;
|
Format | Assembly Format | Description |
---|---|---|
prefixref |
public static readonly OpCode Refanytype;
|
Format | Assembly Format | Description |
---|---|---|
FE 1D | refanytype | Pushes the type token stored in a typed reference. |
The stack transitional behavior, in sequential order, is:
A typed reference contains a type token and an address to an object instance.
The refanytype instruction retrieves the type token embedded in the typed reference. See the OpCodes.Mkrefany instruction for information on creating typed references.
The following ILGenerator.Emit constructor overload can use the refanytype opcode:
public static readonly OpCode Refanyval;
|
Format | Assembly Format | Description |
---|---|---|
C2 < T > | refanyval | Pushes the address stored in a typed reference. |
The stack transitional behavior, in sequential order, is:
A typed reference contains a type token and an address to an object instance.
The refanyval instruction retrieves the address embedded in the a typed reference. The type embedded in the typed reference supplied on the stack must match the type specified by type (a metadata token, either a typedef or a typeref). See the OpCodes.Mkrefany instruction for related content.
InvalidCastException is thrown if type is not identical to the type stored in the type reference (in this case, type is the class supplied to the OpCodes.Mkrefany instruction that constructed said typed reference).
TypeLoadException is thrown if type cannot be found.
The following ILGenerator.Emit constructor overload can use the refanyval opcode:
public static readonly OpCode Rem;
|
Format | Assembly Format | Description |
---|---|---|
5D | rem | Pushes the remainder of dividing by onto the stack. |
The stack transitional behavior, in sequential order, is:
result = value1remvalue2 satisfies the following conditions:
result = value1-value2× (value1divvalue2), and:
0 = | result | < | value2 |, sign(result) = sign(value1), where div is the division instruction that truncates towards zero.
If value2 is zero or value1 is infinity the result is NaN. If value2 is infinity, the result is value1 (negated for -infinity).
Integral operations throw DivideByZeroException if value2 is zero.
Note that on the Intel-based platforms an OverflowException is thrown when computing (minint rem -1).
The following ILGenerator.Emit constructor overload can use the rem opcode:
public static readonly OpCode Rem_Un;
|
Format | Assembly Format | Description |
---|---|---|
5E | rem.un | Pushes the remainder of dividing unsigned by unsigned onto the stack. |
The stack transitional behavior, in sequential order, is:
result = value1rem.unvalue2 satisfies the following conditions:
result = value1-value2 x (value1div.unvalue2), and:
0 = result < value2, where div.un is the unsigned division instruction.
The rem.un instruction computes result and pushes it on the stack.Rem.un treats its arguments as unsigned integers, while OpCodes.Rem treats them as signed integers.
Rem.un is unspecified for floating-point numbers.
Integral operations throw DivideByZeroException if value2 is zero.
The following ILGenerator.Emit constructor overload can use the rem.un opcode:
public static readonly OpCode Ret;
|
Format | Assembly Format | Description |
---|---|---|
2A | ret | Returns from method, possibly returning a value. |
The stack transitional behavior, in sequential order, is:
If the return value is not present on the callee evaluation stack, no value is returned (no stack transition behaviors for either the callee or caller method).
The type of the return value, if any, of the current method determines the type of value to be fetched from the top of the stack and copied onto the stack of the method that called the current method. The evaluation stack for the current method must be empty except for the value to be returned.
The ret instruction cannot be used to transfer control out of a try, filter, catch, or finally block. From within a try or catch, use the OpCodes.Leave instruction with a destination of a ret instruction that is outside all enclosing exception blocks. Because the filter and finally blocks are logically part of exception handling and not the method in which their code is embedded, correctly generated Microsoft Intermediate Language (MSIL) instructions do not perform a method return from within a filter or finally.
The following ILGenerator.Emit constructor overload can use the ret opcode:
public static readonly OpCode Rethrow;
|
Format | Assembly Format | Description |
---|---|---|
FE 1A | rethrow | Rethrows the current exception |
No stack transition behavior is defined for this instruction.
The rethrow instruction is only permitted within the body of a catch handler. It throws the same exception that was caught by this handler.
The following ILGenerator.Emit constructor overload can use the rethrow opcode:
public static readonly OpCode Shl;
|
Format | Assembly Format | Description |
---|---|---|
62 | shl | Shifts an integer to the left (shifting in zeros). |
The stack transitional behavior, in sequential order, is:
The shl instruction shifts the value (type int32, int64 or natural int) left by the specified number of bits. The number of bits is a value of type int32, int64 or natural int. The return value is unspecified if the number of bits to be shifted is greater than or equal to the width (in bits) of the supplied value.
Shl inserts a zero bit in the lowest position on each shift.
The following ILGenerator.Emit constructor overload can use the shl opcode:
public static readonly OpCode Shr;
|
Format | Assembly Format | Description |
---|---|---|
63 | shr | Shifts an integer to the right (shifting in sign). |
The stack transitional behavior, in sequential order, is:
The shr.un instruction shifts the value (type int32, int64 or natural int) right by the specified number of bits. The number of bits is a value of type int32, int64 or natural int. The return value is unspecified if the number of bits to be shifted is greater than or equal to the width (in bits) of the supplied value.
Shr replicates the high order bit on each shift, preserving the sign of the original value in the result.
The following ILGenerator.Emit constructor overload can use the shr opcode:
public static readonly OpCode Shr_Un;
|
Format | Assembly Format | Description |
---|---|---|
64 | shr.un | Shifts an integer to the right (shifting in zeroes). |
The stack transitional behavior, in sequential order, is:
The shr.un instruction shifts the value (type int32, int64 or natural int) right by the specified number of bits. The number of bits is a value of type int32, int64 or natural int. The return value is unspecified if the number of bits to be shifted is greater than or equal to the width (in bits) of the supplied value.
Shr.un inserts a zero bit in the highest position on each shift.
The following ILGenerator.Emit constructor overload can use the shr.un opcode:
public static readonly OpCode Sizeof;
|
Format | Assembly Format | Description |
---|---|---|
FE 1C < T > | sizeof | Push the size, in bytes, of a value type as an unsigned int32 . |
The stack transitional behavior, in sequential order, is:
ValType must be a metadata token (a typeref or typedef) that specifies a value type.
The following ILGenerator.Emit constructor overload can use the sizeof opcode:
public static readonly OpCode Starg;
|
Format | Assembly Format | Description |
---|---|---|
FE OB < unsigned int16 > | starg | Pops the top value from the stack and stores it in argument slot |
The stack transitional behavior, in sequential order, is:
The starg instruction pops a value from the stack and places it in argument slot num. The type of the value must match the type of the argument, as specified in the current method's signature.
For procedures that take a variable argument list, the starg instruction can be used only for the initial fixed arguments, not those in the variable part of the signature.
Performing a store into arguments that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the argument. Floating-point values are rounded from their native size (type F) to the size associated with the argument.
The following ILGenerator.Emit constructor overload can use the starg opcode:
public static readonly OpCode Starg_S;
|
Format | Assembly Format | Description |
---|---|---|
10 < unsigned int8 > | starg.s | Pops the top value from the stack and stores it in argument slot , short form. |
The stack transitional behavior, in sequential order, is:
The starg.s instruction pops a value from the stack and places it in argument slot num. The type of the value must match the type of the argument, as specified in the current method's signature.
The starg.s instruction provides an efficient encoding for use with the first 256 arguments.
For procedures that take a variable argument list, the starg.s instruction can be used only for the initial fixed arguments, not those in the variable part of the signature.
Performing a store into arguments that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the argument. Floating-point values are rounded from their native size (type F) to the size associated with the argument.
The following ILGenerator.Emit constructor overload can use the starg.s opcode:
public static readonly OpCode Stelem_I;
|
Format | Assembly Format | Description |
---|---|---|
9B | stelem.i | Replaces an array element at the supplied index with the natural int value on the stack. |
The stack transitional behavior, in sequential order, is:
The stelem.i instruction replaces the value of the element index in the one-dimensional array array with the natural int value pushed onto the stack.
Arrays are objects and hence represented by a value of type O. The index is type natural int.
NullReferenceException is thrown if array is a null reference.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
ArrayTypeMismatchException is thrown if array does not hold elements of the required type.
The following ILGenerator.Emit constructor overload can use the stelem.i opcode:
public static readonly OpCode Stelem_I1;
|
Format | Assembly Format | Description |
---|---|---|
9C | stelem.i1 | Replaces an array element at the supplied index with the int8 value on the stack. |
The stack transitional behavior, in sequential order, is:
The stelem.i1 instruction replaces the value of the element index in the one-dimensional array array with the int8 value pushed onto the stack.
Arrays are objects and hence represented by a value of type O. The index is type natural int.
NullReferenceException is thrown if array is a null reference.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
ArrayTypeMismatchException is thrown if array does not hold elements of the required type.
The following ILGenerator.Emit constructor overload can use the stelem.i1 opcode:
public static readonly OpCode Stelem_I2;
|
Format | Assembly Format | Description |
---|---|---|
9D | stelem.i2 | Replaces an array element at the supplied index with the int16 value on the stack. |
The stack transitional behavior, in sequential order, is:
The stelem.i2 instruction replaces the value of the element index in the one-dimensional array array with the int16 value pushed onto the stack.
Arrays are objects and hence represented by a value of type O. The index is type natural int.
NullReferenceException is thrown if array is a null reference.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
ArrayTypeMismatchException is thrown if array does not hold elements of the required type.
The following ILGenerator.Emit constructor overload can use the stelem.i2 opcode:
public static readonly OpCode Stelem_I4;
|
Format | Assembly Format | Description |
---|---|---|
9E | stelem.i4 | Replaces an array element at the supplied index with the int32 value on the stack. |
The stack transitional behavior, in sequential order, is:
The stelem.i4 instruction replaces the value of the element index in the one-dimensional array array with the int32 value pushed onto the stack.
Arrays are objects and hence represented by a value of type O. The index is type natural int.
NullReferenceException is thrown if array is a null reference.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
ArrayTypeMismatchException is thrown if array does not hold elements of the required type.
The following ILGenerator.Emit constructor overload can use the stelem.i4 opcode:
public static readonly OpCode Stelem_I8;
|
Format | Assembly Format | Description |
---|---|---|
9F | stelem.i8 | Replaces an array element at the supplied index with the int64 value on the stack. |
The stack transitional behavior, in sequential order, is:
The stelem.i8 instruction replaces the value of the element index in the one-dimensional array array with the int64 value pushed onto the stack.
Arrays are objects and hence represented by a value of type O. The index is type natural int.
NullReferenceException is thrown if array is a null reference.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
ArrayTypeMismatchException is thrown if array does not hold elements of the required type.
The following ILGenerator.Emit constructor overload can use the stelem.i8 opcode:
public static readonly OpCode Stelem_R4;
|
Format | Assembly Format | Description |
---|---|---|
A0 | stelem.r4 | Replaces an array element at the supplied index with the float32 value on the stack. |
The stack transitional behavior, in sequential order, is:
The stelem.r4 instruction replaces the value of the element index in the one-dimensional array array with the float32 value pushed onto the stack.
Arrays are objects and hence represented by a value of type O. The index is type natural int.
NullReferenceException is thrown if array is a null reference.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
ArrayTypeMismatchException is thrown if array does not hold elements of the required type.
The following ILGenerator.Emit constructor overload can use the stelem.r4 opcode:
public static readonly OpCode Stelem_R8;
|
Format | Assembly Format | Description |
---|---|---|
A1 | stelem.r8 | Replaces an array element at the supplied index with the float64 value on the stack. |
The stack transitional behavior, in sequential order, is:
The stelem.r8 instruction replaces the value of the element index in the one-dimensional array array with the float64 value pushed onto the stack.
Arrays are objects and hence represented by a value of type O. The index is type natural int.
NullReferenceException is thrown if array is a null reference.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
ArrayTypeMismatchException is thrown if array does not hold elements of the required type.
The following ILGenerator.Emit constructor overload can use the stelem.r8 opcode:
public static readonly OpCode Stelem_Ref;
|
Format | Assembly Format | Description |
---|---|---|
A2 | stelem.ref | Replaces an array element at the supplied index with the ref value (type O ) on the stack. |
The stack transitional behavior, in sequential order, is:
The stelem.ref instruction replaces the value of the element at the supplied index in the one-dimensional array array with the ref (type O) value pushed onto the stack.
Arrays are objects and hence represented by a value of type O. The index is type natural int.
Note that stelem.ref implicitly casts the supplied value to the element type of array before assigning the value to the array element. This cast can fail, even for verified code. Thus the stelem.ref instruction can throw InvalidCastException. For one-dimensional arrays that aren't zero-based and for multidimensional arrays, the Array class provides a Array.SetValue method.
NullReferenceException is thrown if array is a null reference.
IndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.
ArrayTypeMismatchException is thrown if array does not hold elements of the required type.
The following ILGenerator.Emit constructor overload can use the stelem.ref opcode:
public static readonly OpCode Stfld;
|
Format | Assembly Format | Description |
---|---|---|
7D < T > | stfld | Replaces the value of of the object with a new value. |
The stack transitional behavior, in sequential order, is:
The stfld instruction replaces the value of a field of an object (type O) or via a pointer (type natural int, &, or *) with a givne value.Field is a metadata token that refers to a field member reference. The stfld instruction can have a prefix of either or both of OpCodes.Unaligned and OpCodes.Volatile.
NullReferenceException is thrown if the object reference or pointer is a null reference and the field isn't static.
MissingFieldException is thrown if field is not found in the metadata. This is typically checked when the Microsoft Intermediate Language (MSIL) instruction is converted to native code, not at runtime.
The following ILGenerator.Emit constructor overload can use the stfld opcode:
public static readonly OpCode Stind_I;
|
Format | Assembly Format | Description |
---|---|---|
DF | stind.i | Stores a natural int value at at a given address. |
The stack transitional behavior, in sequential order, is:
The stind.i instruction stores a natural int value at the supplied address (type natural int, *, or &).
Type safe operation requires that the stind.i instruction be used in a manner consistent with the type of the pointer. The operation of the stind.i instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
NullReferenceException is thrown if addr is not naturally aligned for the argument type implied by the instruction suffix.
The following ILGenerator.Emit constructor overload can use the stind.i opcode:
public static readonly OpCode Stind_I1;
|
Format | Assembly Format | Description |
---|---|---|
52 | stind.i1 | Stores an int8 value at at a given address. |
The stack transitional behavior, in sequential order, is:
The stind.i1 instruction stores an int8 value at the supplied address (type natural int, *, or &).
Type safe operation requires that the stind.i1 instruction be used in a manner consistent with the type of the pointer. The operation of the stind.i1 instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
NullReferenceException is thrown if addr is not naturally aligned for the argument type implied by the instruction suffix.
The following ILGenerator.Emit constructor overload can use the stind.i1 opcode:
public static readonly OpCode Stind_I2;
|
Format | Assembly Format | Description |
---|---|---|
53 | stind.i2 | Stores an int16 value at at a given address. |
The stack transitional behavior, in sequential order, is:
The stind.i2 instruction stores an int16 value at the supplied address (type natural int, *, or &).
Type safe operation requires that the stind.2i instruction be used in a manner consistent with the type of the pointer. The operation of the stind.i2 instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
NullReferenceException is thrown if addr is not naturally aligned for the argument type implied by the instruction suffix.
The following ILGenerator.Emit constructor overload can use the stind.i2 opcode:
public static readonly OpCode Stind_I4;
|
Format | Assembly Format | Description |
---|---|---|
54 | stind.i4 | Stores an int32 value at at a given address. |
The stack transitional behavior, in sequential order, is:
The stind.i4 instruction stores an int32 value at the supplied address (type natural int, *, or &).
Type safe operation requires that the stind.i4 instruction be used in a manner consistent with the type of the pointer. The operation of the stind.i4 instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
NullReferenceException is thrown if addr is not naturally aligned for the argument type implied by the instruction suffix.
The following ILGenerator.Emit constructor overload can use the stind.i4 opcode:
public static readonly OpCode Stind_I8;
|
Format | Assembly Format | Description |
---|---|---|
55 | stind.i8 | Stores an int64 value at at a given address. |
The stack transitional behavior, in sequential order, is:
The stind.i8 instruction stores an int64 value at the supplied address (type natural int, *, or &).
Type safe operation requires that the stind.i8 instruction be used in a manner consistent with the type of the pointer. The operation of the stind.i instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
NullReferenceException is thrown if addr is not naturally aligned for the argument type implied by the instruction suffix.
The following ILGenerator.Emit constructor overload can use the stind.i8 opcode:
public static readonly OpCode Stind_R4;
|
Format | Assembly Format | Description |
---|---|---|
56 | stind.r4 | Stores a float32 value at at a given address. |
The stack transitional behavior, in sequential order, is:
The stind.r4 instruction stores a float32 value at the supplied address (type natural int, *, or &).
Type safe operation requires that the stind.r4 instruction be used in a manner consistent with the type of the pointer. The operation of the stind.r4 instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
NullReferenceException is thrown if addr is not naturally aligned for the argument type implied by the instruction suffix.
The following ILGenerator.Emit constructor overload can use the stind.r4 opcode:
public static readonly OpCode Stind_R8;
|
Format | Assembly Format | Description |
---|---|---|
57 | stind.r8 | Stores a float64 value at at a given address. |
The stack transitional behavior, in sequential order, is:
The stind.r8 instruction stores a float64 value at the supplied address (type natural int, *, or &).
Type safe operation requires that the stind.r8 instruction be used in a manner consistent with the type of the pointer. The operation of the stind.r8 instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
NullReferenceException is thrown if addr is not naturally aligned for the argument type implied by the instruction suffix.
The following ILGenerator.Emit constructor overload can use the stind.r8 opcode:
public static readonly OpCode Stind_Ref;
|
Format | Assembly Format | Description |
---|---|---|
51 | stind.ref | Stores an object reference (type O ) value at a given address. |
The stack transitional behavior, in sequential order, is:
The stind.ref instruction stores an object reference value at the supplied address (type natural int, *, or &).
Type safe operation requires that the stind.ref instruction be used in a manner consistent with the type of the pointer. The operation of the stind.ref instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
NullReferenceException is thrown if addr is not naturally aligned for the argument type implied by the instruction suffix.
The following ILGenerator.Emit constructor overload can use the stind.ref opcode:
public static readonly OpCode Stloc;
|
Format | Assembly Format | Description |
---|---|---|
FE 0E < unsigned int16 > | stloc | Pops a value from the stack and stores it in local variable |
The stack transitional behavior, in sequential order, is:
The stloc instruction pops the top value off the evalution stack and moves it into local variable number index, where local variables are numbered 0 onwards. The type of the value must match the type of the local variable as specified in the current method's local signature.
Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type F) to the size associated with the argument.
Correct Microsoft Intermediate Language (MSIL) instructions require that index be a valid local index. For the stloc instruction, index must lie in the range 0 to 65534 inclusive (specifically, 65535 is not valid). The reason for excluding 65535 is pragmatic: likely implementations will use a 2-byte integer to track both a local's index, as well as the total number of locals for a given method. If an index of 65535 had been made valid, it would require a wider integer to track the number of locals in such a method.
The following ILGenerator.Emit constructor overload can use the stloc opcode:
public static readonly OpCode Stloc_0;
|
Format | Assembly Format | Description |
---|---|---|
0A | stloc.0 | Pops a value from the stack into local variable 0. |
The stack transitional behavior, in sequential order, is:
The stloc.0 instruction pops the top value off the evalution stack and moves it into the local variable indexed by 0. The type of the value must match the type of the local variable as specified in the current method's local signature.
stloc.0 is an especially efficient encoding for storing values in local variable 0.
Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type F) to the size associated with the argument.
The following ILGenerator.Emit constructor overload can use the stloc.0 opcode:
public static readonly OpCode Stloc_1;
|
Format | Assembly Format | Description |
---|---|---|
0B | stloc.1 | Pops a value from the stack into local variable 1. |
The stack transitional behavior, in sequential order, is:
The stloc.1 instruction pops the top value off the evalution stack and moves it into the local variable indexed by 1. The type of the value must match the type of the local variable as specified in the current method's local signature.
stloc.1 is an especially efficient encoding for storing values in local variable 1.
Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type F) to the size associated with the argument.
The following ILGenerator.Emit constructor overload can use the stloc.1 opcode:
public static readonly OpCode Stloc_2;
|
Format | Assembly Format | Description |
---|---|---|
0C | stloc.2 | Pops a value from the stack into local variable 2 |
The stack transitional behavior, in sequential order, is:
The stloc.2 instruction pops the top value off the evalution stack and moves it into the local variable indexed by 2. The type of the value must match the type of the local variable as specified in the current method's local signature.
stloc.2 is an especially efficient encoding for storing values in local variable 2.
Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type F) to the size associated with the argument.
The following ILGenerator.Emit constructor overload can use the stloc.2 opcode:
public static readonly OpCode Stloc_3;
|
Format | Assembly Format | Description |
---|---|---|
0D | stloc.3 | Pops a value from the stack into local variable 3 |
The stack transitional behavior, in sequential order, is:
The stloc.3 instruction pops the top value off the evalution stack and moves it into the local variable indexed by 3. The type of the value must match the type of the local variable as specified in the current method's local signature.
stloc.3 is an especially efficient encoding for storing values in local variable 3.
Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type F) to the size associated with the argument.
The following ILGenerator.Emit constructor overload can use the stloc.3 opcode:
public static readonly OpCode Stloc_S;
|
Format | Assembly Format | Description |
---|---|---|
13 < unsigned int8 > | stloc.s | Pops a value from the stack and stores it in local variable short form. |
The stack transitional behavior, in sequential order, is:
The stloc.s instruction pops the top value off the evalution stack and moves it into local variable number index, where local variables are numbered 0 onwards. The type of the value must match the type of the local variable as specified in the current method's local signature.
The stloc.s instruction provides an efficient encoding for local variables 0 through 255.
Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type F) to the size associated with the argument.
The following ILGenerator.Emit constructor overload can use the stloc.s opcode:
public static readonly OpCode Stobj;
|
Format | Assembly Format | Description |
---|---|---|
81 < T > | stobj | Stores a value of type from the stack into memory. |
The stack transitional behavior, in sequential order, is:
The stobj instruction copies the value type object into the address specified by the address (a pointer of type natural int, *, or &). The number of bytes copied depends on the size of the class represented by class, a metadata token representing a value type.
The operation of the stobj instruction can be altered by an immediately preceding OpCodes.Volatile or OpCodes.Unaligned prefix instruction.
TypeLoadException is thrown if class cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at run time.
The following ILGenerator.Emit constructor overload can use the stobj opcode:
public static readonly OpCode Stsfld;
|
Format | Assembly Format | Description |
---|---|---|
80 < T > | stsfld | Replaces the value in with a supplied value. |
The stack transitional behavior, in sequential order, is:
The stsfld instruction replaces the value of a static field with a value from the stack.field is a metadata token that must refer to a static field member.
The stsfld instruction may be prefixed by OpCodes.Volatile.
MissingFieldException is thrown if field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time.
The following ILGenerator.Emit constructor overload can use the stsfld opcode:
public static readonly OpCode Sub;
|
Format | Assembly Format | Description |
---|---|---|
59 | sub | Subtracts one value from another, returning a new numeric value. |
The stack transitional behavior, in sequential order, is:
Overflow is not detected for integer operations (for proper overflow handling, see OpCodes.Sub_Ovf).
Integer subtraction wraps, rather than saturates. For example: assuming 8-bit integers, where value1 is set to 255 and value2 is set to 1, the "wrapped" result will be 0 rather than 256.
Floating-point overflow returns +inf (PositiveInfinity) or -inf (NegativeInfinity).
The following ILGenerator.Emit constructor overload can use the sub opcode:
public static readonly OpCode Sub_Ovf;
|
Format | Assembly Format | Description |
---|---|---|
DA | sub.ovf | Subtracts one integer value from another with an overflow check. |
The stack transitional behavior, in sequential order, is:
OverflowException is thrown if the result can not be represented in the result type.
This operation is performed on signed integers; for floating-point values, use OpCodes.Sub.
The following ILGenerator.Emit constructor overload can use the sub.ovf opcode:
public static readonly OpCode Sub_Ovf_Un;
|
Format | Assembly Format | Description |
---|---|---|
DB | sub.ovf.un | Subtracts one unsigned integer value from anotherwith an overflow check. |
The stack transitional behavior, in sequential order, is:
OverflowException is thrown if the result can not be represented in the result type.
This operation is performed on signed integers; for floating-point values, use OpCodes.Sub.
The following ILGenerator.Emit constructor overload can use the sub.ovf.un opcode:
public static readonly OpCode Switch;
|
Format | Assembly Format | Description |
---|---|---|
45 < unsigned int32 > < int32 > ... < int32 > | switch | Jumps to one of values. |
The stack transitional behavior, in sequential order, is:
The switch instruction implements a jump table. The format of the instruction is an unsigned int32 representing the number of targets N, followed by N int32 values specifying jump targets. These targets are represented as offsets (positive or negative) from the beginning of the instruction following this switch instruction.
The switch instruction pops a value off the stack and compares it, as an unsigned integer, to N. If value is less than N, execution is transferred to the target indexed by value, where targets are numbered from 0 (for example, a value of 0 takes the first target, a value of 1 takes the second target, and so on). If the value is greater than or equal to N, execution continues at the next instruction (fall through).
If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes.
Control transfers into and out of try, catch, filter, and finally blocks cannot be performed by this instruction. (Such transfers are severely restricted and must use the leave instruction instead).
The following ILGenerator.Emit constructor overload can use the switch opcode. The Label[] argument is an array of Labels representing 32-bit offsets.
public static readonly OpCode Tailcall;
|
Format | Assembly Format | Description |
---|---|---|
FE 14 | tail. | Subsequent call terminates current methods |
There is no stack transition behavior defined for this instruction.
The tail. prefix instruction must immediately precede a OpCodes.Call, OpCodes.Calli, or OpCodes.Callvirt instruction. It indicates that the current method's stack frame should be removed before the call instruction is executed. It also implies that the value returned from the following call is also the value returned by the current method, and the call can therefore be converted into a cross-method jump.
The stack must be empty except for the arguments being transferred by the following call. The instruction following the call instruction must be a ret. Thus the only valid code sequence is tail. call (or calli or callvirt). Correct Microsoft Intermediate Language (MSIL) instructions must not branch to the call instruction, but they may branch to the subsequent OpCodes.Ret.
The current frame cannot be discarded when control is transferred from untrusted code to trusted code, since this would jeopardize code identity security. The .NET Framework security checks can therefore cause the tail. to be ignored, leaving a standard OpCodes.Call instruction. Similarly, in order to allow the exit of a synchronized region to occur after the call returns, the tail. prefix is ignored when used to exit a method that is marked synchronized.
The following ILGenerator.Emit constructor overload can use the tail. opcode:
public static readonly OpCode Throw;
|
Format | Assembly Format | Description |
---|---|---|
7A | throw | Throws an exception. |
The stack transitional behavior, in sequential order, is:
The throw instruction throws the exception object (type O) currently on the stack.
NullReferenceException is thrown if the object reference is a null reference.
The following ILGenerator.Emit constructor overload can use the throw opcode:
public static readonly OpCode Unaligned;
|
Format | Assembly Format | Description |
---|---|---|
FE 12 < unsigned int8 > | unaligned. | Indicates that the subsequent pointer instruction may be unaligned. |
The stack transitional behavior, in sequential order, is:
Unaligned. specifies that the address (an unmanaged pointer, natural int) on the stack might not be aligned to the natural size of the immediately following ldind, stind, ldfld, stfld, ldobj, stobj, initblk, or cpblk instruction. That is, for a OpCodes.Ldind_I4 instruction the alignment of the address may not be to a 4-byte boundary. For initblk and cpblk the default alignment is architecture dependent (4-byte on 32-bit CPUs, 8-byte on 64-bit CPUs). Code generators that do not restrict their output to a 32-bit word size must use unaligned. if the alignment is not known at compile time to be 8-byte.
The value of alignment must be 1, 2, or 4 and means that the generated code should assume that the address is byte, double-byte, or quad-byte aligned, respectively. Note that transient pointers (type *) are always aligned.
While the alignment for a cpblk instruction would logically require two numbers (one for the source and one for the destination), there is no noticeable impact on performance if only the lower number is specified.
The unaligned. and volatile. prefixes can be combined in either order. They must immediately precede a ldind, stind, ldfld, stfld, ldobj, stobj, initblk, or cpblk instruction. Only the OpCodes.Volatile prefix is allowed for the OpCodes.Ldsfld and OpCodes.Stsfld instructions.
The following ILGenerator.Emit constructor overloads can use the unaligned opcode:
public static readonly OpCode Unbox;
|
Format | Assembly Format | Description |
---|---|---|
79 < T > | unbox | Extracts the value type data from , its boxed representation. |
The stack transitional behavior, in sequential order, is:
A value type has two separate representations within the the Common Language Infrastructre (CLI):
The unbox instruction converts the object reference (type O), the boxed representation of a value type, to a value type pointer (a managed pointer, type &), its unboxed form. The supplied value type (valType) is a metadata token indicating the type of value type contained within the boxed object.
Unlike OpCodes.Box, which is required to make a copy of a value type for use in the object, unbox is not required to copy the value type from the object. Typically it simply computes the address of the value type that is already present inside of the boxed object.
InvalidCastException is thrown if the object is not boxed as valType.
NullReferenceException is thrown if the object reference is a null reference.
TypeLoadException is thrown if the value type valType cannot be found. This is typically detected when Microsoft Internediate Language (MSIL) instructions are converted to native code, rather than at runtime.
The following ILGenerator.Emit constructor overload can use the unbox opcode:
public static readonly OpCode Volatile;
|
Format | Assembly Format | Description |
---|---|---|
FE 13 | volatile. | Indicates that the subsequent pointer reference is volatile. |
The stack transitional behavior, in sequential order, is:
volatile. specifies that the address is a volatile address (that is, it can be referenced externally to the current thread of execution) and the results of reading that location cannot be cached or that multiple stores to that location cannot be suppressed. Marking an access as volatile. affects only that single access; other accesses to the same location must be marked separately. Access to volatile locations need not be performed atomically.
The OpCodes.Unaligned and volatile. prefixes can be combined in either order. They must immediately precede a ldind, stind, ldfld, stfld, ldobj, stobj, initblk, or cpblk instruction. Only the volatile. prefix is allowed for the OpCodes.Ldsfld and OpCodes.Stsfld instructions.
The following ILGenerator.Emit constructor overload can use the volatile. opcode:
public static readonly OpCode Xor;
|
Format | Assembly Format | Description |
---|---|---|
61 | xor | Computes the bitwise XOR of two integer values and returns an integer. |
The stack transitional behavior, in sequential order, is:
The xor instruction computes the bitwise XOR of the top two values on the stack and leaves the result on the stack.
Xor is an integer-specific operation.
The following ILGenerator.Emit constructor overload can use the xor opcode:
~OpCodes(); |
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
inst
Otherwise, it returns false.
public virtual string ToString(); |