Menu

#4 Improve ZAPF's branch size optimization

open
nobody
Assembler (4)
7
2010-08-31
2010-04-29
Tara McGrew
No

ZAPF takes multiple passes through the code to find label addresses and optimize operand sizes. This is complicated and usually requires at least 4 passes. It should be possible to assemble in a single pass using Inform-style backpatching: when an operand refers to a label whose value isn't known with 100% certainty, assume it'll fit into short form, then go back later and insert extra bytes where needed.

Discussion

  • Tara McGrew

    Tara McGrew - 2010-08-25
    • priority: 5 --> 7
     
  • Tara McGrew

    Tara McGrew - 2010-08-25

    When code contains a lot of labels (like DeZapf output), the multiple pass method becomes inefficient or unusable. The backpatching method is probably necessary.

     
  • Tara McGrew

    Tara McGrew - 2010-08-31
    • summary: Switch to pure backpatching for ZAPF --> Improve ZAPF's branch size optimization
     
  • Tara McGrew

    Tara McGrew - 2010-08-31

    Backpatching may not be the greatest solution after all. The paper "Assembling Code for Machines with Span-Dependent Instructions" by Thomas Szymanski describes an efficient algorithm for optimizing branch sizes under constraints that are reasonable for ZAPF, using two assembly passes and three auxiliary structures.

    This algorithm will let us eliminate ZAPF's multiple measuring passes and mid-pass reassembly, reducing complexity and run time, without the need to buffer and alter the object code that is emitted. We will need to change the symbol table representation, though: information about local labels must be tracked across passes.

     

Log in to post a comment.