Re: [Q] Assembling with variable length instructions

"Joachim Durchholz" <joachim.durchholz@halstenbach.com.or.de>
16 Feb 2000 23:42:36 -0500

          From comp.compilers

Related articles
[Q] Assembling with variable length instructions jonbelson@hotmail.com (Jonathan Belson) (2000-02-15)
Re: [Q] Assembling with variable length instructions harley@corton.inria.fr (Robert Harley) (2000-02-16)
Re: [Q] Assembling with variable length instructions jejones@microware.com (James Jones) (2000-02-16)
Re: [Q] Assembling with variable length instructions joachim.durchholz@halstenbach.com.or.de (Joachim Durchholz) (2000-02-16)
Re: [Q] Assembling with variable length instructions peterm@gwe.net (Peter Morse) (2000-02-19)
| List of all articles for this month |
From: "Joachim Durchholz" <joachim.durchholz@halstenbach.com.or.de>
Newsgroups: comp.compilers
Date: 16 Feb 2000 23:42:36 -0500
Organization: Compilers Central
References: 00-02-070
Keywords: assembler, comment

> What I've done is to run the first pass assuming that each SDI is
> long, noting the location and target of each SDI in a table. Then
> between the first and second passes, iterate over the table looking
> for an instruction that is long but could be short, shorten it, and
> adjust symbol table values appropriately. Repeat until you don't find
> any more. This isn't perfectly optimal, but it's close and runs
> reasonably fast. There was a paper by Szymanski on SDIs in the CACM
> in the early 1970s that lays out all of the theory. -John]


I'd do it the other way round: start assuming that every SDI is short,
then look which of them have a too-large span and change them to use
longer instructions; repeat passes through the code until nothing
changes.


This will get you an optimal solution provided that all instructions
with a larger span are also longer (unlike the above algorithm that
may not find all possibilities for optimization; from a theory point
of view, my algorithm will give the least fixpoint of the solution
while John's algorithm with give the largest fixpoint).


Regards,
Joachim
[I'd better dig up Szymanski's paper and see what the problem with
iterating up is. -John]


Post a followup to this message

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