Difference between revisions of "Instruction set: CIL"
From ScienceZero
(→Objects) |
(→Objects) |
||
Line 436: | Line 436: | ||
|- | |- | ||
|Stobj || Copies a value of a specified type from the evaluation stack into a supplied memory address. | |Stobj || Copies a value of a specified type from the evaluation stack into a supplied memory address. | ||
+ | |} | ||
+ | |||
+ | |||
+ | ==Memory blocks== | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Name !! Description | ||
+ | |- | ||
+ | |Cpblk || Copies a specified number bytes from a source address to a destination address. | ||
+ | |- | ||
+ | |Initblk || Initializes a specified block of memory at a specific address to a given size and initial value. | ||
+ | |- | ||
+ | |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. | ||
|} | |} | ||
Revision as of 04:36, 9 October 2007
Contents
Arithmetic
Name | Description |
---|---|
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. |
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. |
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. |
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. |
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. |
Logical and shift
Name | Description |
---|---|
And | Computes the bitwise AND of two values and pushes the result onto the evaluation stack. |
Or | Compute the bitwise complement of the two integer values on top of the stack and pushes the result onto the evaluation stack. |
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. |
Xor | Computes the bitwise XOR of the top two values on the evaluation stack, pushing the result onto the evaluation stack. |
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. |
Compares
Name | Description |
---|---|
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. |
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. |
Load constants
Name | Description |
---|---|
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). |
Branching
Add ".S" for short form.
Name | Description |
---|---|
Br | Unconditionally transfers control to a target instruction. |
Beq | Transfers control to a target instruction 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.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 | Transfers control to a target instruction 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. |
Ble | Transfers control to a target instruction 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. |
Blt | Transfers control to a target instruction 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. |
Bne.Un | Transfers control to a target instruction when two unsigned integer values or unordered float values are not equal. |
Brfalse | Transfers control to a target instruction if value is false, a null reference (Nothing in Visual Basic), or zero. |
Brtrue | Transfers control to a target instruction if value is true, not null, or non-zero. |
Calling methods
Name | Description |
---|---|
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. |
Ret | Returns from the current method, pushing a return value (if present) from the callee's evaluation stack onto the caller's evaluation stack. |
Jmp | Exits current method and jumps to specified method. |
Local variables
Name | Description |
---|---|
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. |
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). |
Arguments
Name | Description |
---|---|
Arglist | Returns an unmanaged pointer to the argument list of the current 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. |
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. |
Arrays
Name | Description |
---|---|
Newarr | Pushes an object reference to a new zero-based, one-dimensional array whose elements are of a specific type onto the evaluation stack. |
Ldlen | Pushes the number of elements of a zero-based, one-dimensional array onto the evaluation stack. |
Readonly | Specifies that the subsequent array address operation performs no type check at run time, and that it returns a managed pointer whose mutability is restricted. |
Ldelem | Loads the element at a specified array index onto the top of the evaluation stack as the type specified in the instruction. |
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). |
Stelem | Replaces the array element at a given index with the value on the evaluation stack, whose type is specified in the instruction. |
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. |
Indirect access
Name | Description |
---|---|
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. |
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. |
Fields
Name | Description |
---|---|
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. |
Stfld | Replaces the value stored in the field of an object reference or pointer with a new value. |
Ldsfld | Pushes the value of a static field onto the evaluation stack. |
Ldsflda | Pushes the address of a static field onto the evaluation stack. |
Stsfld | Replaces the value of a static field with a value from the evaluation stack. |
Conversions
Name | Description |
---|---|
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 evaluation stack 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 unsigned natural int, throwing OverflowException on overflow. |
Conv.Ovf.U.Un | Converts the unsigned value on top of the evaluation stack to unsigned natural 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 unsigned int8 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 unsigned int64, 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 unsigned natural 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 unsigned int16, 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 unsigned int64, and extends it to int64. |
Objects
Name | Description |
---|---|
Castclass | Attempts to cast an object passed by reference to the specified class. |
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). |
Initobj | Initializes all the fields of the object at a specific address to a null reference or a 0 of the appropriate primitive type. |
Ldobj | Copies the value type object pointed to by an address to the top of 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. |
Isinst | Tests whether an object reference (type O) is an instance of a particular class. |
Ldnull | Pushes a null reference (type O) onto the evaluation stack. |
Stobj | Copies a value of a specified type from the evaluation stack into a supplied memory address. |
Memory blocks
Name | Description |
---|---|
Cpblk | Copies a specified number bytes from a source address to a destination address. |
Initblk | Initializes a specified block of memory at a specific address to a given size and initial value. |
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. |