Translation of source code

Jan 16, 2011 at 9:59am
hi guys i like this forum ,this is my new thread>>

when we write the program in c++"any program"
and we want execute it"run it" or to make EXE file,,

the source code of program convert directly to machine language "0 1" by compiler
or the source code first convert to assembly language then the assembly convert to machine language???

and if the source code first convert to assembly language"not directly to machine language" what is the purpose (why not convert directly to machine language)???

thanx
Jan 16, 2011 at 11:59am
It depends on the compiler. But generally it should compile it directly into machine code. Why would anyone write two compilers instead of one?

and if the source code first convert to assembly language"not directly to machine language" what is the purpose (why not convert directly to machine language)???
Assembly is very close to how the computer thinks, so when compiling it might be easier to progressively make the code more and more easy to be executed by the CPU.
Jan 16, 2011 at 1:40pm
thank you for reply first,

Assembly is very close to how the computer thinks, so when compiling it might be easier to progressively make the code more and more easy to be executed by the CPU.


yeah it make easy i understanding you,,

Addition:: i think that a compiler can not know the machine language for all type of CPUs,, then it first translate the source code to assembly,, then use an assembler "know the machine code of the CPU that work on it"
Jan 16, 2011 at 1:47pm
Addition:: i think that a compiler can not know the machine language for all type of CPUs,, then it first translate the source code to assembly,, then use an assembler "know the machine code of the CPU that work on it"

Probably true. But as always, every compiler has its own style of working...
Topic archived. No new replies allowed.