What does compiling mean?

Asked

Viewed 20,870 times

12

I have some questions about the process of compiling a code:

  • What is the compilation process? How it works?
  • What are the steps in the compilation process?
  • What is the difference between build x mount (Assembler)

1 answer

12


What is the compilation process?

Compilation is the act / process of translating a program done in a high-level language into a machine language, so that its instructions are executed by the processor, ie creates the executable of a program written in a high-level language.

## How it works?

A sequence of Analises: Léxica, Sintática e Semântica on top of the source code in order to identify the respective errors, an intermediate code is generated (if I do not miss the memory of the middleman of the c is an extension file .o), an optimization of this code is made and the construction of the same for certain architecture (x86, amd64, Arm, Sparc) at the end of the process has a machine code (in windows for example the .exe), is made the binding of methods and libraries (The process follows a sequence pipes e filtros basically).

Below is an example that demonstrates the sequence flow of the process:

inserir a descrição da imagem aqui

What are the steps in the compilation process?

  1. Preprocessing (Join lines that have been separated by exhaust sequences; Removes comments and replaces them with whitespace; Expands macros; Processes pre-processing directives (usually compiler guidelines)).

    1. Lexicographic analysis.

    2. Analise Sintatica.

    3. Analise Semantica.

    4. Generate intermediate code.

    5. Code optimization.

    6. Generates object code for a given architecture (different architectures work completely differently ex: Parc reads strings in the opposite way to x86).

    7. Generates machine code for the given architecture (it is in this phase that is called the linker (its function is to replace all function calls and variable accesses in object files with the actual address)).

What is the difference between build x mount (Assembler).

The assembly is performed to translate a program into assembly language (Assembly) for its binary language equivalent through the assembler. has usually the following steps:

  1. replace the symbolic names of the operation code and operands.
  2. Reserve memory space for storing instructions and data.
  3. Convert constant values to binary code.
  4. Examine the correctness of each instruction.

Disciplines and Books where these concepts are taught:

Computer Architecture

Logic (is taught about drifting trees (used in the processes of analysis))

Programming Languages (we see at intermediate level everything about the analysis and the whole process itself) - ROBERT W. SEBESTA Programming Languages

Compiler Theory

Browser other questions tagged

You are not signed in. Login or sign up in order to post.