Similarities and differences between assembly languages and IL

Source: Internet
Author: User

This article is original. If you need to reprint it, please indicate the author and the source. Thank you!

I can see that many people are discussing compilation and IL in the park recently. I can't help but say a few words. Let's first look at what assembly is. The first thing to know is that assembly is related to CPU commands. The instruction sets of Intel and AMD CPUs are different (of course, some of the commands may be the same ). This requires the corresponding Assembler for different CPUs. The assembler function is to translate the assembler mnemonic signs (such as ADD and mov) into machine codes of a certain type of CPU, finally, binary files such as EXE, DLL, and so are generated.

Since the machine commands of different CPUs are not exactly the same, how can we compile a cross-CPUProgramWhat about it? Of course, a good idea is that there is a general language through which the compiler canSource codeConvert (compile) commands into different CPUs. But there is a problem, that is, it is difficult to implement different compilers for various CPUs. For convenience, You can first convert the language into an assembly language. Then, use the assembler on different CPU platforms to convert the code into a machine code. In this way, the compiler can only have one, and the compiler needs to implement different CPUs. However, it is much easier to compile the compiler. The language we just mentioned is a high-level language, such as C and C ++. Here, assembly language not only plays the role of mnemonic, but also plays the abstract role of CPU. For different CPUs, a note can have different CPU instruction codes.
Let's look at Il. Different. Net-based languages have different syntaxes. CLR is not interested in the syntax of the language, but is only interested in the actual running commands, just like the CPU, just interested in machine commands. Therefore, a language is required to describe the executable commands that CLR can recognize. This is Il. We can compare it with the position of the Assembly. In. net, CLR is A. net virtual machine, which is equivalent to "CPU + operating system. VB.net and C # are equivalent to advanced languages, which are the same as C and C ++. But what about Il is equivalent to the status of assembly, and it is just like the past and the future. It is very fast for CLR to re-compile il into machine commands. Therefore, we can draw a conclusion. If Il is an assembly, this Assembly is not relative to the CPU, but to the CLR. That is to say, Il is a CLR assembly. CLR can be called a. Net Virtual Machine. Therefore, il can be calledVirtual Assembly.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.