Difference between a compiler and an assembler?
What is the difference between compiling and assembling? Most of the things I have read about them (in textbooks and on the web) haven't really said "a compiler does this, an assembler does this". Part of the reason I'm asking is because I have been studying C++ and I've been looking at assembly language. Can I run assembly code from my Bloodshed compiler?
Then there are text editors...ok, maybe I'll leave those alone for now!
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.
Clear enough? That's kind of a rough description of the process... I'm sure others will elaborate.
& the hat of GPL slaying
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.