Re: Best tools for writing an assembler?

Ivan Godard <ivan@ootbcomp.com>
Mon, 24 Feb 2014 15:13:44 -0800

          From comp.compilers

Related articles
[11 earlier articles]
Re: Best tools for writing an assembler? noitalmost@cox.net (noitalmost) (2014-02-23)
Re: Best tools for writing an assembler? sebastien.fricker@gmail.com (=?ISO-8859-1?Q?S=E9bastien_Fricker?=) (2014-02-24)
Re: Best tools for writing an assembler? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-02-24)
Re: Best tools for writing an assembler? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-02-24)
Re: Best tools for writing an assembler? lkrupp@pssw.com (Louis Krupp) (2014-02-24)
Re: Best tools for writing an assembler? ivan@ootbcomp.com (Ivan Godard) (2014-02-24)
Re: Best tools for writing an assembler? ivan@ootbcomp.com (Ivan Godard) (2014-02-24)
Re: Best tools for writing an assembler? james.harris.1@gmail.com (James Harris) (2014-02-24)
Re: Best tools for writing an assembler? hu47121@usenet.kitty.sub.org (2014-02-25)
Re: Best tools for writing an assembler? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2014-02-25)
Re: Best tools for writing an assembler? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2014-02-25)
Re: Best tools for writing an assembler? rpw3@rpw3.org (2014-02-25)
Re: Best tools for writing an assembler? walter@bytecraft.com (Walter Banks) (2014-02-27)
[4 later articles]
| List of all articles for this month |
From: Ivan Godard <ivan@ootbcomp.com>
Newsgroups: comp.compilers
Date: Mon, 24 Feb 2014 15:13:44 -0800
Organization: A noiseless patient Spider
References: 14-02-018 14-02-025 14-02-027 14-02-033
Keywords: assembler, comment
Posted-Date: 24 Feb 2014 22:16:10 EST

On 2/24/2014 12:42 PM, glen herrmannsfeldt wrote:


<snip>




> -- 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]
>


Shrink is not NP, it is exact using a relaxation algorithm: track pairs
of addresses, one the smallest address assuming all unresolved are
resolved short, and one largest assuming all unresolved address are
long. Resolve long all those spreads whose shortest is longer than the
longest short; resolve short all those spreads whose longest is shorter
than than the longest short. Iterate resolution until you do a pass in
which no more were resolved. Set any remaining unresolved to short.


In practice, three iterations are always sufficient, including the final
one that resolves nothing.
[With some assumptions about chaining variable length jumps,
it really is NP-complete. See this 1978 CACM article
http://dx.doi.org/10.1145/359460.359474 -John]


Post a followup to this message

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