Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo Pascal - <b> overlay create program overlays pp 149</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 OVERLAY                   Create Program Overlays                    pp 149

 Syntax:  Overlay [Procedure] [Function] ;

 Type:    N/A

 Form:    Declaration

 Purpose: Allow multiple sections of code to share the same address space.

 Notes:   The overlay system allows the creation of programs that can be much
          larger than available memory permits.  The technique is to collect
          a number of subprograms in one or more files separate from the main
          program file, which can then be loaded into the same address space.

          An overlay group is a collection of subprograms in a common file
          that will be loaded into the same address space one at a time.
          A section of memory is allocated for the overlay area and is sized
          to hold the largest of the single subprograms.

 Caveats: Overlay programs in the same group share the same area in memory
          and thus cannot be loaded concurrently.  They must therefore not
          call each other.  An overlay may call another overlay that resides
          in a separate overlay file, because they will load and execute in
          two different overlay areas of the main program.

          Overlay programs can not be forward declared.  This may be
          easily circumvented by forward declaring an ordinary subprogram
          that in turn calls the overlay subprogram.

          Overlay program can not be recursive.  This is also circumvented
          by declaring an ordinary recursive subprogram that in turn calls
          the overlay subprogram.

          Run-time errors occurring in overlays are found as usual, and an
          address is issued by the error handling system.  This address is
          within the overlay area, and there is no way of knowing which
          subprogram was active at the time of the failure.


 Consecutive Overlays:

          Overlay Procedure One ;
             Begin
             End ;

          Overlay Procedure Two ;
             Begin
             End ;

          Overlay Procedure Three ;
             Begin
             End ;


          These three overlays will be in a common group and reside in a
          common overlay file (FileName.000).  None can call the others.



 Non-Consecutive Overlays:

          Overlay Procedure One ;       { Overlay.000 file }
             Begin
             End ;

          Overlay Procedure Two ;       { Overlay.000 file               }
             Begin
             End ;

          Procedure Not_An_Overlay ;    { Force a separation of overlays }
             Begin
             End ;

          Overlay Procedure Three ;     { Overlay.001 file               }
             Begin
             End ;

          The first two subprograms will be in a common overlay group and
          in the first overlay file, Overlay.000.

          The third subprogram will be in a separate overlay group which
          loads in a separate overlay area in memory, and will reside in
          the second overlay file, Overlay.001.

See Also: Function OverPath Procedure

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson