CIL Instruction Set

> Arithmetic instructions

>> Binary arithmetic instructions

add						// add numeric values
add.ovf.<signed>		// add integer values with overflow check

sub						// subtract numeric values
sub.ovf.<type>			// subtract integer values with overflow check

mul						// multiply numeric values
mul.ovf.<type>			// multiply integer values with overflow check

div						// divide numeric values
div.un					// divide integer values, unsigned

rem						// compute numeric remainder
rem.un					// compute integer remainder, unsigned

and						// bitwise AND
or						// bitwise OR
xor						// bitwise XOR

shl						// shift integer left
shr						// shift integer right
shr.un					// shift integer right, unsigned

>> Unary arithmetic instructions

neg						// negate
not						// bitwise complement

> Branch instructions

>> Conditional branch instructions

beq.<length>			// branch on equal
bge.<length>			// branch on greater than or equal to
bge.un.<length>			// branch on greater than or equal to, unsigned or unordered
bgt.<length>			// branch on greater than
bgt.un.<length>			// branch on greater than, unsigned or unordered
ble.<length>			// branch on less than or equal to
ble.un.<length>			// branch on less than or equal to, unsigned or unordered
blt.<length>			// branch on less than
blt.un.<length>			// branch on less than, unsigned or unordered
bne.un<length>			// branch on not equal or unordered
brfalse.<length>		// branch on false, null, or zero
brtrue.<length>			// branch on non-false or non-null

switch					// table switch based on value

>> Unconditional branch instructions

br.<length>				// unconditional branch
leave.<length>			// exit a protected region of code
ret						// return from method

> Call instructions

call					// call a method
callvirt				// call a method associated, at runtime, with an object
calli					// indirect method call
jmp						// jump to method

> Compare instructions

ceq						// compare equal
cgt						// compare greater than
cgt.un					// compare greater than, unsigned or unordered
clt						// compare less than
clt.un					// compare less than, unsigned or unordered

isinst					// test if an object is an instance of a class or interface

> Convert instructions

conv.<to type>			// data conversion
conv.ovf.<to type>		// data conversion with overflow check
conv.ovf.<to type>.un	// data conversion with overflow check, unsigned

box						// convert a boxable value to its boxed form
castclass				// cast an object to a class

unbox					// convert boxed value type to its raw form
unbox.any				// convert boxed type to value

> Memory instructions

localloc				// allocate space in the local dynamic memory pool
initblk					// initialize a block of memory to a value
cpblk					// copy data from memory to memory

cpobj					// copy a value from one address to another
initobj					// initialize the value at an address

newarr					// create a zero-based, one-dimensional array
newobj					// create a new object

> Exception handling instructions

endfilter				// end exception handling filter clause
endfinally				// end finally or fault clause of an exception block

throw					// throw an exception
rethrow					// rethrow the current exception

> Load instructions

ldc.<type>				// load numeric constant
ldstr					// load a literal string
ldnull					// load a null pointer

ldarg.<length>			// load argument onto the stack
ldloc					// load local variable onto the stack

ldind.<type>			// load a value indirect onto the stack
ldobj					// copy a value from an address to the stack

ldarga.<length>			// load argument address
ldloca.<length>			// load local variable address

ldftn					// load method pointer
ldvirtftn				// load virtual method pointer

ldelem					// load array element
ldelem.<type>			// load array element
ldelema					// load array element address

ldfld					// load object field
ldflda					// load object field address

ldsfld					// load class static field
ldsflda					// load class static field address

ldlen					// load array length

ldtoken					// load the runtime representation of a metadata token

> Store instructions

starg.<length>			// store to argument
stloc					// store to local variable

stind.<type>			// store a value indirect from stack
stobj					// store a value at an address from stack

stelem					// store array element
stelem.<type>			// store array element

stfld					// store object field
stsfld					// store class static field

> Other instructions

arglist					// get argument list

break					// breakpoint instruction

ckfinite				// check for a finite real number

nop						// no operation
dup						// duplicate the top value of the stack
pop						// remove the top element of the stack

mkrefany				// push a typed reference on the stack
refanytype				// load the type out of a typed reference
refanyval				// load the address out of a typed reference

sizeof					// load the size, in bytes, of a type
