UnicMinds

Compilers&Assemblers

Compilers, Assemblers, Linkers and Loaders – what are they?

User writes a program in C or C++ language (high-level language). The C compiler compiles the program and translates it to an assembly program (low-level language). An assembler then translates the assembly program into machine code (object). A linker tool is used to link all the parts of the program together for execution (executable machine code). A loader loads all of them into memory and then the program is executed.

compilers for kids
linker for kids

Compiler:

It converts the source code into the assembly code.

Assembler:

It converts the assembly code into object code.

Linker:

It combines the multiple object files into a single executable program file or into a library file.

Loader:

It loads the executable file into main memory.

Then, what is an Interpreter?

Compiler does everything and then executes, whereas Interpreter does everything including execution line by line. For example, an interpreter, like a compiler, translates high-level language into low-level machine language. The difference lies in the way they read the source code or input. A compiler reads the whole source code at once, creates tokens, checks semantics, generates intermediate code, executes the whole program and may involve many passes. In contrast, an interpreter reads a statement from the input, converts it to an intermediate code, executes it, then takes the next statement in sequence. If an error occurs, an interpreter stops execution and reports it. whereas a compiler reads the whole program even if it encounters several errors.

Hope this is useful, thank you.

BOOK A FREE TRIAL