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: Hans-Peter Diettrich Newsgroups: comp.compilers Subject: Re: Best tools for writing an assembler? Date: Tue, 25 Feb 2014 04:23:40 +0100 Organization: Compilers Central Lines: 20 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-02-040@comp.compilers> References: <14-02-018@comp.compilers> <14-02-025@comp.compilers> <14-02-027@comp.compilers> <14-02-033@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: miucha.iecc.com 1393545992 67791 64.57.183.58 (28 Feb 2014 00:06:32 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 28 Feb 2014 00:06:32 +0000 (UTC) Keywords: assembler, optimize Posted-Date: 27 Feb 2014 19:06:32 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:1119 glen herrmannsfeldt schrieb: > There are some interesting cases where the instruction choice (and > length) depends on the size of an address, which (in the case of a > forward reference) depends on the instruction length. If you can > avoid that, it is pretty easy. > > -- glen > [Variable length instructions aren't that hard. You start by assuming > everything will be the long form, then iterate over the code a few > times shrinking what you can. That isn't always perfectly optimal > (which is known to be NP complete), but it's pretty close. -John] Hmm, I'd start with the *shortest* encoding, and extend whatever doesn't fit afterwards. This avoids "deadlocks", resulting from kind of circular references. Indeed harder is reordering parts of the code, in order to reduce the number of long references - kind of "travelling salesman" problem? DoDi