|[Q] Assembling with variable length instructions firstname.lastname@example.org (Jonathan Belson) (2000-02-15)|
|Re: [Q] Assembling with variable length instructions email@example.com (Robert Harley) (2000-02-16)|
|Re: [Q] Assembling with variable length instructions firstname.lastname@example.org (James Jones) (2000-02-16)|
|Re: [Q] Assembling with variable length instructions email@example.com (Joachim Durchholz) (2000-02-16)|
|Re: [Q] Assembling with variable length instructions firstname.lastname@example.org (Peter Morse) (2000-02-19)|
|From:||Robert Harley <email@example.com>|
|Date:||16 Feb 2000 23:39:38 -0500|
Jonathan Belson <firstname.lastname@example.org> 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
(If you needed to stop after two iterations, say, to limit compile
time then iterating from above would certainly be the way to go).
[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
Search the comp.compilers archives again.