[Programming IL] Starting from Hello World

Source: Internet
Author: User
Tags mscorlib
Glossary

IL = Intermediate Language, in. net is designed to become the Common Intermediate Language, and because the Council itself is universal, Microsoft designed an implementation for him. On the Microsoft platform, we can also call it MSIL.

Target

It provides a specific implementation for the underlying design of the. Net platform, the features of the basic programming language, such as process control, Judgment, arithmetic computing, and address. There are also specific object-oriented designs, relationships between classes, hiding, inheritance, interfaces, and so on. More support for functional languages, understanding IL is not only a deep understanding of the program, but also an important basis for the Framework of. Net Framework. I personally think

Basic knowledge

Every. Net application or assembly is actually a PE (Portable Execution) file. Details about the PE file format and so on will be described later.

Instance-starting from HelloWrold

Code:

   1: .assembly extern mscorlib {}
   2: .assembly hello {}
   3: .method static public void main() cil managed
   4: {
   5:     .entrypoint
   6:     .maxstack 1
   7:     ldstr "Hello world!"
   8:     call void [mscorlib]System.Console::WriteLine(class System.String)
   9:     ret
  10: }

1. mscorlib is located in % Windows %/Microsoft. NET/Framework/v2.0.50727. It is the basis for the interaction between. Net programs and APIs, and contains the implementation of the basic class library (BCL ).

2. Set the Assembly name to hello.

3 ....

5. entrypoint entry point

6. Allocate stacks

7. load string

8. Call Method

9. Return

 

I have been learning about IL for a long time and have recently explored it. net Design and other things. I started to look at IL for a while. I was busy with my work. Instead, I put it on hold. I didn't write this thing for anything, but I just urged myself.

Reference books:

Expert. NET 2.0 IL Explorer

Common Language Infrastructure Partition II

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.