Re: Is Assembler Language essential in compiler construction?

"cr88192" <cr88192@hotmail.com>
Mon, 16 Feb 2009 07:48:24 +1000

          From comp.compilers

Related articles
[12 earlier articles]
Re: Is Assembler Language essential in compiler construction? cr88192@hotmail.com (cr88192) (2009-02-12)
Re: Is Assembler Language essential in compiler construction? marcov@stack.nl (Marco van de Voort) (2009-02-13)
Re: Is Assembler Language essential in compiler construction? tony@my.net (Tony) (2009-02-14)
Re: Is Assembler Language essential in compiler construction? walter@bytecraft.com (Walter Banks) (2009-02-14)
Re: Is Assembler Language essential in compiler construction? anton@mips.complang.tuwien.ac.at (2009-02-14)
Re: Is Assembler Language essential in compiler construction? ArarghMail902@Arargh.com (2009-02-14)
Re: Is Assembler Language essential in compiler construction? cr88192@hotmail.com (cr88192) (2009-02-16)
Re: Is Assembler Language essential in compiler construction? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-02-16)
Re: Is Assembler Language essential in compiler construction? cr88192@hotmail.com (cr88192) (2009-02-18)
Re: Is Assembler Language essential in compiler construction? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-02-19)
Re: VM as target, was Is Assembler Language essential cr88192@hotmail.com (cr88192) (2009-02-21)
Re: VM as target, was Is Assembler Language essential gneuner2@comcast.net (George Neuner) (2009-02-21)
Re: VM as target, was Is Assembler Language essential cr88192@hotmail.com (cr88192) (2009-02-23)
[12 later articles]
| List of all articles for this month |

From: "cr88192" <cr88192@hotmail.com>
Newsgroups: comp.compilers
Date: Mon, 16 Feb 2009 07:48:24 +1000
Organization: albasani.net
References: 09-02-021 09-02-037
Keywords: assembler, translator
Posted-Date: 15 Feb 2009 18:36:50 EST

"Torben "Fgidius" Mogensen" <torbenm@pc-003.diku.dk> wrote in message
> 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.
>


however, targetting a VM may not always be an option, or at least not a good
one...


consider the case where much of the code is generated at runtime, in which
case, to use an existing VM requires linking it into the app, bringing along
any external dependency and liscensing issues with it (is the library
commercial? will it force all your stuff to become GPL? ...).


as well, with a VM one is usually bound (almost with an iron rope) to
whatever are the biases (personal, political, and practical), of the person
or community which maintains and develops this particular VM (though, yes,
this is not as significant an issue with JVM or .NET, but would be a much
bigger issue with many of the smaller and more specialized VMs...).


also, one may become roped to a particular VM and architecture, given that
VMs typically do not interop well with each other (creating the risk that an
eventual change could force one to abandon said VM, thus losing much of what
effort was invested into using it).




targetting assembler may allow a much lighter-weight compiler (that one
themselves controls).
this is because one can, in effect, write their own assembler for their own
uses, or if they really must depend on one, it is a much lighter-weight
component.


but, as a possible downside, one may end up eventually implementing a
full-scale VM going this route, and one does not automatically get all of
the support that comes with the other VMs...


so, it is all tradeoffs it seems...




> Torben



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.