In the book Galvin,In the topic of overlays it's mentioned lets

  • Thread starter Thread starter prashantgolu
  • Start date Start date
  • Tags Tags
    Book Topic
Click For Summary

Discussion Overview

The discussion revolves around the role of the symbol table in a two-pass assembler as described in the book Galvin, particularly focusing on why the symbol table is included in the first pass and its implications for memory usage and code optimization.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant questions the necessity of including the symbol table in the first pass, suggesting it is the output of that pass.
  • Another participant explains that the symbol table is kept in memory for speed and is built during the first pass to assist in code generation during the second pass.
  • Some participants discuss the conditions under which the symbol table might need to be updated, particularly in relation to code size optimization and forward references.
  • There is mention of how some assemblers may optimize code size by adjusting symbol addresses based on known offsets after the first pass.
  • Participants clarify that the first pass is not repeated; rather, it generates the initial symbol table which is then used in subsequent passes.
  • One participant expresses confusion about the need for the symbol table in the first pass, leading to further clarification about its role in defining symbols and their addresses.

Areas of Agreement / Disagreement

Participants generally agree on the function of the symbol table in the assembly process, but there remains some confusion and debate regarding its inclusion in the first pass and the implications for memory management and code optimization.

Contextual Notes

There are unresolved questions regarding the specific scenarios in which the symbol table needs to be updated and how this affects the overall assembly process, particularly in relation to code size optimization.

prashantgolu
Messages
50
Reaction score
0
In the book Galvin,In the topic of overlays...it's mentioned...
lets take an assembler working in 2 passes...pass 1 which symbol table and 2nd pass which produces machine language...
now
pass-1 70 kb
pass 2 80kb
symbol table 20kb
common routine 30kb

now in the overlay A they include pass 1,common routine,overlay driver and symbol table...

why..to include symbol table...it's the output of the 1st pass...why to include in the 1st pass...??

Thanks
 
Technology news on Phys.org


somebdy please reply...
 


The symbol table is normally kept in memory for speed pursposes. Pass 1 builds a table with symbol values and their relative offsets (addresses) for code and data. Pass 2 then uses the symbol table to help generate the code. For some machnine languages the assembler may auto-optimize to use alternately shorter instructions based on symbol offsets to reduce code size, which requires updating the symbol table and repeating pass 2.
 


srry cldnt understand yr point...why do we need to update symbol table..?
 


prashantgolu said:
srry cldnt understand yr point...why do we need to update symbol table..?
This is rare, only when the assembler is reducing code size. In this case the symbols that refer to code addresses need to be adjusted if the code size is reduced. This was common on some motorola 68000 assemblers. Most intel assemblers will just insert nops to pad code if shorter instruction forms can be used, rather than make multiple passes to reduce code size.
 


"symbols that refer to code addresses need to be adjusted if the code size is reduced."

can u provide some example...i just know the basics of a n assembler...and as far as i know..it replaces the symbols used with their corresponding addresses...so how can the code size be shortened...
 


prashantgolu said:
So how can the code size be shortened?
The code size can be optimized when there are duplicate instructions that vary in size depending on the address or offset of the operand or branch address.

On the first pass, symbols may be referenced before they are defined, called a forwards reference. Since the address is unknown, the assembler will assume a worst case and for instructions that vary in size depending on the address or offset field, the assembler will use the largest instruction size. After the first pass, all local symbols will have addresses or offsets, and all external symbols will have been defined as external. On the second pass, the address or offset on forward references are known, and in this case the assembler can use a shorter instruction size if one is available that will reach the referenced symbol. This will shift all the remaining code downwards a bit. It may turn out that after a second pass reduction in code size, a few more instructions can be reduced in size on a third pass.
 


thanks a lot...!
I got it...but then why should the 1st pass be repeated...?
 


prashantgolu said:
Why should the 1st pass be repeated...?
It isn't. The first pass just gets the initial definition of all the local symbols. Then that information is use on the 2nd (or any later) passes.
 
  • #10


but then we again return to our basic question...that if pass 1 is not to be repeated..but just symbol table is to be updated...then why to include symbol table in pass 1..?
 
  • #11


prashantgolu said:
pass 1 is not to be repeated..but just symbol table is to be updated...then why to include symbol table in pass 1..?
Pass 1 creates the symbol table. It generates entries each time a symbol is defined or referenced (forward reference), and then fills in the address or offset or declares it external as it goes through the first pass and finds out how to define the symbols address or offset. It also does enough of the code generation to know the size of each instruction so that symbols used as labels for instructions get the proper address or offset.
 
  • #12


exactly...so symbol table is the output of pass 1...not the input...

*i am getting most of it..just a little doubt is still there*
 
  • #13


prashantgolu said:
so symbol table is the output of pass 1
yes, but it will need to have the memory space to hold the symbol table as it creates it.
 
  • #14


yaa..this was what i was thinking...THanks a LOT...!
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
Replies
12
Views
6K
  • · Replies 7 ·
Replies
7
Views
3K
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 32 ·
2
Replies
32
Views
5K
Replies
15
Views
4K