Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news.linkpendium.com!news.linkpendium.com!news.iecc.com!.POSTED!nerds-end From: Robert A Duff Newsgroups: comp.compilers Subject: Re: Best tools for writing an assembler? Date: Wed, 19 Feb 2014 18:20:33 -0500 (EST) Organization: The World Public Access UNIX, Brookline, MA Lines: 28 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-02-023@comp.compilers> References: <14-02-018@comp.compilers> <14-02-021@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: miucha.iecc.com 1392966862 33590 64.57.183.58 (21 Feb 2014 07:14:22 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 21 Feb 2014 07:14:22 +0000 (UTC) Keywords: assembler Posted-Date: 21 Feb 2014 02:14:21 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1102 Ivan Godard writes: >...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. Good idea, except I'd write it in Ada or OCaml or something. I've done something similar. You can do all sorts of powerful things this way, because you have the full power of C++ (or whatever) at your fingertips. And if you want to write a compiler for some higher-level language, it can call those same "add" routines. I've never liked the compiler design that has the compiler generate assembly language as text, and then feed that text to a traditional assembler (even though I've written such compilers). It seems needlessly inefficient. The only sensible argument in favor of that is that it's the only way to ensure that the assembler and the compiler agree on all the bit-wise encodings of op-codes and so forth. In other words, it's the only way to sufficiently test the assembler (since nobody writes large amounts of assembly by hand anymore). But your idea here solves that problem nicely -- there IS no assembler in the tradition sense. Just the "add" and so forth routines. - Bob