What does it mean to compile?

8

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

  • What is the build process? How does it work?
  • What are the steps in the build process?
  • What is the difference between compilation x assembly (Assembler)
asked by anonymous 10.05.2015 / 19:34

1 answer

7

What is the build process?

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

## How does it work?

A sequence of Analises: Léxica, Sintática e Semântica is made on top of the source code in order to identify its errors, an intermediate code is generated (if the memory does not fail me, the intermediate of the compile process of c is a (x86, amd64, arm, sparc) at the end of the process there is a machine code (in windows, for example .o ), it is done an optimization of this code and the construction of same for a given architecture , the .exe of methods and libraries are done (The process follows a binding sequence basically).

Below is an example that demonstrates the process stream:

Whatarethestagesofthecompilationprocess?

  • Preprocessing(Joinlinesthathavebeenseparatedbyescapesequences;Removescommentsandreplacesthemwithwhitespace;Expandsmacros;Itprocessespreprocessingdirectives(usuallycompilerorientations).)

  • Lexical analysis.

  • Syntactic Analysis.

  • Semantic Analysis.

  • Generate intermediate code.

  • Code optimization.

  • It generates object code for a certain architecture (different architectures work in a totally different way eg sparc read strings in a way that is contrary to x86).

  • Generate machine code for the given architecture (this is what is called pipes e filtros (its function is to replace all function calls and accesses to variables in object files by the actual address))

  • What is the difference between compilation x assembly (Assembler).

    Assembly is performed to translate an assembly language program into its binary equivalent through the assembler. usually has the following steps:

  • replace the symbolic names of operation codes and operands.
  • Reserve memory space for storing instructions and data.
  • Convert values from constants to binary code.
  • Examine the fix for each statement.
  •   

    Disciplines and Books where these concepts are taught:

    Computer Architecture

    Logic (is taught about derivation trees (used in analysis processes))

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

    Compiler Theory

        
    10.05.2015 / 21:59