IL Code

By now we already know the role of IL code as a language-independent format in which to express instructions. However, its generic nature extends in the other direction, too: Being an intermediate representation, it also allows decoupling from the specifics of any underlying hardware platform. The result is a very generic instruction set that’s rich enough to express the needs of various languages and simple enough to be mapped onto processor instructions, as we’ll see later.

Let’s take a closer look at one of the methods declared in our program (the Calculator’s Add method). Here’s what it looks like:

.method public hidebysig instance int32  Add(int32 a,                                             int32 b) cil managed{  .maxstack  8 ...

Get C# 4.0 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.