Home > Common Problem > What is needed to convert a program written in a high-level programming language into an equivalent executable program?

What is needed to convert a program written in a high-level programming language into an equivalent executable program?

王林
Release: 2023-02-13 13:48:38
Original
31396 people have browsed it

Converting a program written in a high-level programming language into an equivalent executable program requires compilation and linking. High-level programming languages ​​can get rid of the different constraints of computer instruction systems and machine language random machines, and convert source programs into target codes that the CPU can recognize.

What is needed to convert a program written in a high-level programming language into an equivalent executable program?

#The operating environment of this article: windows10 system, thinkpad t480 computer.

Converting a program written in a high-level programming language into an equivalent executable program requires compilation and linking.

The source program written by the user is compiled into the target program, but this program cannot be run yet. Because the standard function subroutines and input/output subroutines used in the program have not yet been linked in. Therefore, it must be connected and assembled to become an independent runnable program.

Introduction to high-level programming language

High-level programming language, also known as "algorithm language", referred to as "high-level language". A programming language for writing programs in a formal language that is easy to write and understand. It can get rid of the different constraints of computer instruction systems and machine language random machines, and design corresponding compilers (or "compilers") to convert source programs written in high-level languages ​​suitable for various machines into ones that can be recognized by the central processor. target code.

According to the basic specifications for describing the calculation process, it is divided into procedural languages ​​(such as FORTRAN language, PASCAL language, Ada language, etc.), functional languages ​​(such as LISP language), logical languages ​​(such as PROLOG language) and Object-oriented languages ​​(composed by adding some description mechanisms to support object-oriented languages ​​on the previous languages).

The interpreter is a type of high-level language translation program. It takes a source program written in the source language as input and interprets it into a binary code recognized by the machine. After interpreting a sentence, it submits it to the computer for execution. It does not form a target program. .

Editing is to write the source program. Compilation refers to taking a high-level language source program as input, performing translation and conversion to produce a target program in machine language, and then letting the computer execute the target program.

Convert source program to executable program

To run a program, it must go through four steps: preprocessing, compilation, assembly and linking.

1. Preprocessing: Aggregate source programs (.c files) stored in different files, and replace macros in the language, such as the preprocessing directive #include, to let the compiler open the included files. , keep its program together with other programs. Generate .i files.

2. Compilation: Preprocessing source program (.i file) into assembler (.s file)

3. Assembly (assember): Convert assembler into relocatable ( relocatable: that is, the machine code of the code segment and data address in the file has not yet been finalized). This step generates the target file (.obj or .o file).

4. Linker/loader: Linking is to connect the target file with other program modules (if any) that are compiled and generated separately and the standard library functions provided by the system to generate The process of creating a runnable executable file locates each code and data in the appropriate location in the memory during loading. This step generates the final executable file.

What is needed to convert a program written in a high-level programming language into an equivalent executable program?

Extended knowledge:

  • Source program:

    Source program refers to uncompiled A text file written in accordance with certain programming language specifications is a series of human-readable computer language instructions.

    The source program cannot be executed directly on the computer. You need to use a "compiler" to compile the source program into binary form of code.

  • Target program:

    The binary code obtained by compiling the source program through the "compiler" is called the target program

    The target program refers to the source program after Compile a collection of machine codes that can be directly run by the computer, and use .obj as the extension on the computer file

  • Executable program

    Executable program: compile all The obtained target modules are connected and assembled, and then connected with the function library to form a whole, generating a target program that can be executed by the computer and becoming an executable program.

    Simply put, an executable program is a complete program that can be independently executed under the operating system by connecting the target program and the library function.

    The extension of the executable program is ".exe ” (in dos/windows environment).

(Learning video sharing: Programming video)

The above is the detailed content of What is needed to convert a program written in a high-level programming language into an equivalent executable program?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template