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

  • Thread starter prashantgolu
  • Start date
  • Tags
    Book Topic
In summary, the book Galvin mentions that overlays are used in order to include pass 1, common routine, and symbol table in one pass. The purpose of including the symbol table is to reduce code size on pass 2.
  • #1
prashantgolu
50
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
  • #2


somebdy please reply...
 
  • #3


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.
 
  • #4


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


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.
 
  • #6


"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...
 
  • #7


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.
 
  • #8


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


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...!
 

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

1. What is the book Galvin about?

The book Galvin is a comprehensive guide to operating systems, covering topics such as process management, memory management, and file systems.

2. What are overlays?

Overlays are a memory management technique used in computer systems to allow programs to use more memory than is physically available.

3. How are overlays used in operating systems?

In operating systems, overlays are used to load and swap out sections of a program's code or data into memory as needed, allowing the program to run without requiring all of its memory to be loaded at once.

4. What is the purpose of overlays?

The purpose of overlays is to allow programs to use more memory than is physically available, thus improving the efficiency and performance of the system.

5. Are overlays still used in modern operating systems?

While overlays were commonly used in older operating systems, they are not as widely used in modern systems due to advancements in memory management techniques and the availability of larger memory capacities.

Similar threads

Replies
4
Views
1K
Replies
12
Views
1K
  • Programming and Computer Science
Replies
1
Views
598
  • Science and Math Textbooks
Replies
2
Views
2K
  • Programming and Computer Science
Replies
32
Views
3K
Replies
15
Views
1K
Replies
19
Views
1K
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
Back
Top