当前位置:网站首页>Compilation process of program

Compilation process of program

2022-06-11 20:34:00 I running

Catalog

1. Program translation environment and execution environment

Translation environment :

execution environment :

2. Compilation phase

​ precompile 、 compile 、 assembly 、 The link process is shown in the figure : 

 3. Running environment

The execution of a program


Every source program needs to be read by the machine and can run , Produce the effect we want , Both need to go through the process of translation and linking , This article will take you through the process of program translation and linking , Lead everyone to see the unknown process before the program runs .

1. Program translation environment and execution environment

stay ANSI C In any implementation of , There are two different environments

Translation environment :

In this environment, source code is converted into executable machine instructions .

execution environment :

Used to actually execute code .

In the translation environment c Original code of language , After processing, it is converted into binary file test.c, It contains binary instructions / Machine instructions , After processing in the running environment, we can generate the desired results .

There are two parts in the translation environment: Compilation and linking .

The source file is compiled into a file with .obj Target file for suffix

The target file is generated by linking the linker and the link library .exe For suffix executable .

 

2. Compilation phase

Overview of translation environment :

precompile 、 compile 、 assembly 、 The link process is shown in the figure : 

 3. Running environment

The execution of a program :

1. The program must be loaded into memory .

In an operating system environment : This is usually done by the operating system . In an independent environment , The loading of the program must be arranged manually , It can also be done by putting executable code into read-only memory .
2. The execution of the procedure begins , And then I call main function .

3. Start executing program code ( Execute in the order we write the code ).

At this time, the program will use a runtime Stack (stack, Function stack frame ), Store function local variables and return address . Programs can also use static (static) Memory , Variables stored in static memory retain their values throughout the execution of the program .
4. To terminate the program . Normal termination main function ; It could be an accidental termination .

原网站

版权声明
本文为[I running]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203011745219316.html