Re: Best tools for writing an assembler?

Ivan Godard <ivan@ootbcomp.com>
Tue, 18 Feb 2014 23:23:29 -0800

          From comp.compilers

Related articles
Best tools for writing an assembler? tpphysik@gmail.com (2014-02-18)
Re: Best tools for writing an assembler? cbergstrom@pathscale.com (=?ISO-8859-1?Q?=22C=2E_Bergstr=F6m=22?=) (2014-02-19)
Re: Best tools for writing an assembler? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-02-19)
Re: Best tools for writing an assembler? ivan@ootbcomp.com (Ivan Godard) (2014-02-18)
Re: Best tools for writing an assembler? sebastien.fricker@gmail.com (=?ISO-8859-1?Q?S=E9bastien_Fricker?=) (2014-02-19)
Re: Best tools for writing an assembler? bobduff@TheWorld.com (Robert A Duff) (2014-02-19)
Re: Best tools for writing an assembler? bobduff@shell01.TheWorld.com (Robert A Duff) (2014-02-19)
Re: Best tools for writing an assembler? tpphysik@gmail.com (=?ISO-8859-1?Q?Patrik_T=FAri?=) (2014-02-20)
Re: Best tools for writing an assembler? sebastien.fricker@gmail.com (=?ISO-8859-1?Q?S=E9bastien_Fricker?=) (2014-02-21)
Re: Best tools for writing an assembler? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2014-02-21)
[18 later articles]
| List of all articles for this month |
From: Ivan Godard <ivan@ootbcomp.com>
Newsgroups: comp.compilers
Date: Tue, 18 Feb 2014 23:23:29 -0800
Organization: A noiseless patient Spider
References: 14-02-018
Keywords: assembler
Posted-Date: 19 Feb 2014 17:22:56 EST

On 2/18/2014 4:04 PM, tpphysik@gmail.com wrote:
> I want to write an assembler for my own processor architecture. It
> would be of middle complexity. ...


I strongly recommend the approach we took in the Mill assembler: we
use the C++ compiler as the first pass, then execute the resulting
program as the second pass. You write a C++ function for each machine
operation: "add(regNum r1, regNum r2)" or whatever. The bodies of each
of these call the emitters with the bit pattern to use, and the
emitters pack the bits into the output.


Note that the C++ forms the meta-language which is traditionally a macro
language. Thus you can rite:
    for(int i=0; i < 8; ++i)
            store(b+4*i, regs[i]);
and get the eight stores to flush your registers.


We actually generate all the function definitions from our specification
machinery, but you can wrte them by hand too, and the work will still be
much less than writing, debugging and documenting a traditional assembler.


Post a followup to this message

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