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) |
From: | Robert Harley <harley@corton.inria.fr> |
Newsgroups: | comp.compilers |
Date: | 16 Feb 2000 23:39:38 -0500 |
Organization: | I.N.R.I.A Rocquencourt |
References: | 00-02-070 |
Keywords: | assembler |
Jonathan Belson <jonbelson@hotmail.com> writes:
> Since the instruction size is unknown until I know all the label
> addresses, and the label addresses can't be fully determined until all
> the instruction sizes are known, I can't see that simple two-pass
> assembling will work in this case.
Our moderor replies:
> [Span-dependent-instructions (SDI) [...]
>
> 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.
Surely it would be better to initially assume that all are short and
then iteratively lengthen some as required. Since you iterate all the
way to a fix-point, you might as well iterate from below and get a
fix-point as least as good and possibly better than by iterating from
above.
(If you needed to stop after two iterations, say, to limit compile
time then iterating from above would certainly be the way to go).
Bye,
Rob.
[As I recall, there are some pathological cases where iterating up
doesn't work. An advantage of iterating down is that all of states
that you iterate through are valid programs, rather than iterating
through invalid ones looking for one that's OK. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.