Basic IL

The CLR is what causes your code to execute. The CLR is like a virtual CPU. Just like your x86 CPU pulls in an instruction at a time (with pre-fetch, cache, and so forth, it might not be as simple as that, but logically, this is what is happening), you can think of the CLR as pushing and pulling variables from the stack and executing instructions. That doesn't happen in real life, but the model forms a basis for understanding IL. Because IL is “intermediate,” it cannot depend on a CPU execution model. It cannot assume that registers will be available, even though most modern CPUs have registers; the number and types of registers vary greatly between CPUs. IL does not even have the concept of registers. IL is completely stack based. Instruction ...

Get .NET Common Language Runtime Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.