Who converts High Level Language to Assembly language

assemblycompilation

Well Going through basic Functioning of computer's instruction /program, I learnt that We write source code in High Level Language.Compilers convert it into low level language (Machine code/object code). I also learnt that Assembler converts assembly language into machine code/object code.
Then I have got following doubts:

  1. From where this assembly language is generated if compilers directly convert high level to low level.

  2. if the conversion process has to go through assembly language i.e

High Level Language ====> Assembly language ====> object code/machine code,
then who converts this high level language to assembly language and what is the use of it?

Best Answer

This is a very general question (and also a bit difficult to understand, to be honest).

A compiler for a high-level language could convert high level code into assembler and a secondary utility could convert assembler into what you call machine code. A compiler could also produce machine code directly. Either option is valid and it is up to the compiler's designers to determine which is most appropriate.

That said, assembly is one step away from being "machine code", so it is often useful to be able to read it to determine what the compiler has done. Sometimes this will lead to insights that allow one to optimize the high level code; other times, a 1337 programmer might opt to edit the assembly by hand. For this reason, even if a compiler appears to produce machine code directly, it is often the case that it can produce assembly code instead.

See this SO answer for further details.

Related Topic