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
AI Thread Summary
The discussion revolves around the role of the symbol table in a two-pass assembler process. In the first pass, the assembler creates the symbol table, which includes symbol values and their relative offsets. This table is crucial for the second pass, where the actual machine code is generated. The inclusion of the symbol table in the overlay is justified because it is essential for speed, allowing quick access to symbol information during code generation.The conversation highlights that while the first pass is not repeated, the symbol table may need updates if code size is optimized, particularly in cases where the assembler can use shorter instructions based on known addresses from the first pass. This optimization is less common in Intel assemblers, which typically use padding instead of multiple passes for code reduction. The symbol table is thus an output of the first pass, but it must be maintained in memory to facilitate efficient code generation in subsequent passes.
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...!
 
Back
Top