Re: Writing Assembler!

Ben Bullock <>
17 May 1997 00:09:16 -0400

          From comp.compilers

Related articles
Writing Assembler! (Khoo Kiak Wei) (1997-05-13)
Re: Writing Assembler! (1997-05-14)
Re: Writing Assembler! (Clark L. Coleman) (1997-05-16)
Re: Writing Assembler! (1997-05-17)
Re: Writing Assembler! (Ben Bullock) (1997-05-17)
Re: Writing Assembler! (1997-05-17)
Re: Writing Assembler! (Mr J R Hall) (1997-05-22)
Re: Writing Assembler! (JUKKA) (1997-05-22)
Re: Writing Assembler! (Charles Fiterman) (1997-05-22)
Re: Writing Assembler! (1997-05-25)
Re: Writing Assembler! (1997-05-25)
[12 later articles]
| List of all articles for this month |

From: Ben Bullock <>
Newsgroups: comp.compilers
Date: 17 May 1997 00:09:16 -0400
Organization: University of Cambridge, England
References: 97-05-156
Keywords: assembler, parse

Khoo Kiak Wei wrote:

> I am planning to write a generic assembler, as a work of learning
> flex and bison. However, after reading a book on Lex and Yacc, I am
> still confused on how should I start!?

Is it actually necessary or useful to use bison to write an assembler?
I can't think of where you need to use recursion, unless it's for some
kind of preprocessing.

Also, if you try and make a generic assembler, you are actually
dealing with several different languages.

This doesn't sound like a good place to use flex to me, because you
don't know what patterns you want to match at compile-time.

If you wanted to make an assembler for just one particular instruction
set it might be more useful to use flex.

> If any of you know of any sample code on assembler or good books talking
> on the assembler construction, I would like to hear from you please!

There are several freely available assemblers. One is the gnu generic
assembler gas. Another one is nasm, for intel x86 chips. Neither of
these use things like flex or bison though, except gas uses bison
somewhere for one particular chip (even then it says in the comments
that that is overkill).

Ben Bullock @ Cavendish Laboratory, University of Cambridge, UK.

* FOAM = Fast Operating Algebraic Manipulator - read about it at
the foampage :
download it : *

Post a followup to this message

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