My teacher told me that the intermediate code is generic for all systems but a component of the compiler then make it different according the system/environment the code is run on. Can someone please explain it.
Asked
Active
Viewed 125 times
3
-
Are you talking about the host where the compiler is running or the host where the compiled binary is running on later? – Gerhardh Jul 05 '17 at 07:08
-
Thanks for clarification. If you were asking about the compil**ed** binary, it would go in a different direction. – Gerhardh Jul 05 '17 at 08:19
1 Answers
7
Normally a compiler is divided into two parts: A frontend that does the parsing, and which generates intermediate code. Then a backend which takes the intermediate code and generate the assembly or machine code.
The frontend can be generic, but the backend is built for a specific target. So the compiler doesn't have to "identify" the host, only know the target.
Note that host and target may be different systems, which is used for cross compilation.

Some programmer dude
- 400,186
- 35
- 402
- 621
-
2Well, rather three parts, as the major part of the backend is machine-independent as well - it'd be a hell otherwise. – iehrlich Jul 05 '17 at 07:23