(MSIL) is a language used as the output of a number of compilers (C#, VB, .NET, and so forth).
The ILAsm program (Intermediate Language Assembler) generates an executable file from the MSIL language. We can find this program in the WINNT\Microsoft.NET\Framework\vn.nn.nn directory.
All operations in MSIL are executed on the stack. When a function is called, its parameters and local variables are allocated on the stack. Function code starting from this stack state may push some values onto the stack, make operations with these values, and pop values from the stack.
Execution of both MSIL commands and functions is done in three steps:
- Push command operands or function parameters onto the stack.
- Execute the MSIL command or call function. The command or function pops their operands (parameters) from the stack and pushes onto the stack result (return value).
- Read result from the stack.
Steps 1 and 3 are optional. For example, the void function doesn't push a return value to the stack.
The stack contains objects of value types and references to objects of reference type. Reference type objects are kept in the heap.
MSIL commands used to push values onto the stack are called ld... (load). Commands used to pop values from the stack are called st... (store), because values are stored in variables. Therefore, we will call the push operation loading and the pop operation storing.