Quick Google Search

Difference between a compiler and an assembler?

Compiling is the process of taking higher level language files and combining them with libraries and necessary dependency files. Most compilers will then use a "linker" to link these files together and then use an "assembler" to turn that code into assembly language, and then, if necessary, machine code.

Because your processor processes only assembly instructions or machine language, and it's much easier and faster to write with high level languages, the compiler/assembler does the job of translating this high level code into processor level language.

Actually the libraries are brought in during the linking phase. Prior to that only the headers are brought in.

Basic process from C to machine:
1) Pre-processer: brings in the #includes and resolves the #defines
2) Compiling: Takes the code and turns it into object code. Any external references are left as symbolic references.
3) Linking: Libraries and other object files are combined, all external references are resolved. The output is machine code

Basic Processor from ASM to machine
1) Pre-processor (If supported): Same as above
2) Assembling: Basically the same as above, it takes the code and turns it into object code
3) Linking: Same as above

Now there are some compilers that can output the code in ASM format. That would be after the compiling phase and the linking phase would not occur. At that point you could use an assembler to turn it into object code, then link it, etc. Also you can take the object code and put it into a library. Very few compilers have the ASM phase as a normal step.

No comments:

Popular Posts