Detailed explanation of the program environment

Table of contents

1. Program translation environment and execution environment

1. Translation environment

(1) The translation environment is divided into compiler and linker

(2) Compilation is also divided into 3 steps

2. Execution environment


1. Program translation environment and execution environment

In any implementation of ANSI C, there are two different environments >:
The first is the translation environment, in which the source code is converted into executable machine instructions.
The second is the execution environment, which is used to actually execute the code.

1. Translation environment

(1) The translation environment is divided into compiler and linker

The source code generates an executable program in the translation environment:

Compile + link -----> executable program as shown in the figure:

(2) Compilation is also divided into 3 steps

1. Precompile

2. compile

3. Compilation

As shown in the picture:

2. Execution environment

The process of program execution:
1. The program must be loaded into memory. In an environment with an operating system: generally this is done by the operating system. In an independent environment, the
loading of the program must be arranged manually, or it may be through the executable The code is placed into read-only memory to complete.
2. The execution of the program begins. Then the main function is called.
3. The program code starts to be executed. At this time, the program will use a runtime stack (stack) to store the local variables and return
address of the function. The program can also use static (static) memory at the same time. The variables stored in the static memory
keep their values ​​throughout the execution of the program.
4. Terminate the program. Terminate the main function normally; it may also be terminated unexpectedly
 

Guess you like

Origin blog.csdn.net/llt2997632602/article/details/129966134