From: | torbenm@pc-003.diku.dk (Torben =?iso-8859-1?Q?=C6gidius?= Mogensen) |
Newsgroups: | comp.compilers |
Date: | Wed, 11 Feb 2009 16:46:18 +0100 |
Organization: | Department of Computer Science, University of Copenhagen |
References: | 09-02-021 |
Keywords: | assembler, practice |
Posted-Date: | 11 Feb 2009 17:25:41 EST |
marco.m.petersen@gmail.com writes:
> Is Assembler Language essential in compiler construction? I've read a
> few e-Books on compiler construction and it always says that knowledge
> of assembly is essential.
>
> I mean, if you wrote a program that converts code from BASIC to C++
> then calls another compiler to do the compilation process, wouldn't
> that be considered as a compiler?
It would indeed, but it is not necessarily easier than using an
assembly language -- it depends on how much your language looks like
C++ (or whatever your target HLL is).
Also, compiler textbooks often focus more on making the reader
understand what happens in a typical compiler than training him/her to
write a "real" compiler. Few CS graduates will ever write a
full-scale compiler, but they will all need to understand the cost of
what they write in a HLL, and to do that they need to understand how
the HLL code is eventually executed on a machine. So I don't see this
as a problem. In any case, this focus on understanding makes using
assembly or assembly-like target languages a good choice, where using
another HLL as target language would sweep a lot of details under the
carpet, even if this would be an easier approach.
If I were to write a full-scale compiler these days, I would probably
target a virtual machine instead of assembly language. This could be
JVM, .NET, llvm or something else, depending on my goals. But that
doesn't change the fact that you learn more by trying to write a
compiler that goes all the way to assembly -- even if this is only for
a toy language.
Torben
Return to the
comp.compilers page.
Search the
comp.compilers archives again.