Programs are translated into different formats by other programs.

Source: Internet
Author: User

At the beginning of the life cycle of the hello program, it is a high-level C program, because when in this form, it can be understood by people. However, to run the hello. C program on the system, each c statement must be converted into a series of low-level machine language commands by other programs. These commands are packed in a format called executable object program and stored as binary disk files. The target program is also called an executable target file ).

Preprocessing phase: the pre-processor (CPP) modifies the original C program based on the command starting with "#" (directives. For example, the # include <stdio. h> command in the first line of Hello. c tells the Preprocessor to read the stdio. H content of the system file and insert it directly into the program text. The result shows another C program, usually with. I as the file extension.

Compilation phase: the compiler (CCL) translates the text file hello. I into the text file hello. S, which contains an assembly language program. Each statement in an assembly language program describes a low-level machine language instruction in a standard text format. Assembly language is very useful because it provides a general output language for different compilers in different advanced languages. For example, the C compiler and the Fortran compiler use the same assembly language for output files.

Assembly phase: Next, the assembler (AS) changes hello. S is translated into and its language commands. packaging these commands is called a format called relocatable, and the results are saved in the target file hello. o. The Hello. o file is a binary file whose Byte encoding is machine language instruction rather than character. If we open the hello. o file in the text editor, a pair of garbled characters will be displayed.

Link stage: Please note that the hello program calls the printf function, which is a function in the Standard C library and is provided by every C compiler. The printf function exists in a separate pre-compiled target file named printf. O, which must be incorporated into our hello. O program in some way. The linker (ID) is responsible for processing such integration, and the result is a hello file, which is an executable target file (or executable file ). After an executable file is loaded to the storage, the system is responsible for execution.

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.