If I run a .NET compiler it produces a file containing intermediate language code (IL) and put it into, an .exe file (for instance).
After if I use a tool like ildasm it shows me the IL code again.
However if I write directly into a file IL code then I can use ilasm to produce an .exe file.
What does it contain? IL code again? Is IL code different to IL assembly code?
Is there a difference between IL code and IL assembly?
IL itself is in the binary format which means it can't be read by the human. But as other binary (executable) code have an assembly language, so in the same way IL also has an assembly language known as IL Assembly (ILAsm). IL Assembly has the instruction in the same way that the native assembly language has.
The main difference between machine code and assembly language is that the machine code is a language that consists of binaries that can be directly executed by a computer while an assembly language is a low-level programming language that requires a software called an assembler to convert it into machine code.
What is IL? Languages such as C# or Java are not directly compiled into machine instructions, but another intermediate code. For C# this intermediate code is called Common Intermediate Language (CIL, or just IL). Most Portable Executable (PE) files compiled and assembled from C#, whether .
IL code is compiled by JIT Compiler. JIT Compiler converted IL Code into Machine Code.
Yes, there is a big difference between them, since :
(IL) which is also known as Microsoft Intermediate Language or Common Intermediate Language can be considered very similar to the Byte Code generated by the Java Language, and is what I think you are referring as IL Code in your question .
(ILAsm) has the instruction set same as that the native assembly language has. You can write code for ILAsm in any text editor like notepad and then can use the command line compiler (ILAsm.exe) provided by the .NET framework to compile that.
I think that IL Assembly can be considered a fully fledged .NET language(maybe an intermediate language), so when you compile ILAsm with ILAsm.exe you are producing IL in pretty much the same way(with less steps) that your C# compiler does with C# Code ...
As someone stated in the comment IL Assembly is basically a human readable version of the .NET Byte Code.
A .NET assembly does not contain MSIL, it contains metadata and bytes that represent IL opcodes. Pure binary data, not text. Any .NET decompiler, like ildasm.exe, knows how to convert the bytes back to text. It is pretty straight-forward.
The C# compiler directly generates the binary data, there is no intermediate text format. When you write your own IL code with a text editor then you need ilasm.exe to convert it to binary. It is pretty straight-forward.
The most difficult job of generating the binary data is the metadata btw. It is excessively micro-optimized to make it as small as possible, its structure is quite convoluted. No compiler generates the bytes directly, they'll use a pre-built component to get that job done. Notable is that Roslyn had to rewrite this from scratch, big job.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With