Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  DOS loads an executable program by reading the contents of a .COM or .EXE
  file directly into an area of free memory. The layout of executable code
  and data in memory--the memory map--reflects the structure of the
  executable file, which in turn is primarily determined by the language
  translator you use to compile or assemble your program. Although language
  translators differ, most of them produce executable programs in which
  logically separate portions of the program are mapped in different blocks
  of memory. (See Figure 19-1.)

  This memory map fits comfortably into the addressing schemes that are
  natural to the 8086: The executable code is addressed through the CS
  register; the program data is accessed through the DS and ES registers;
  and the SS register points to the stack.

  Higher addresses +------------------------+
                   |                        |
                   |         Stack          |
                   |------------------------|
                   |                        |
                   |   Uninitialized data   |
                   |------------------------|
                   |                        |
                   |      Program data      |
                   |------------------------|
                   |                        |
                   |    Executable code     |
                   |------------------------|
                   | Program Segment Prefix |
   Lower addresses +------------------------+

  Figure 19-1.  Memory usage in a typical DOS program.

  --------------------------------------------------------------------------
  NOTE:
    This memory map is also practical because it conforms to the memory
    conventions for programs that run in a protected-mode environment like
    OS/2. In protected mode, the 80286 and 80386 require you to use
    particular segment registers to address executable code and data. When
    you write a program to run in protected mode, you must avoid storing
    data values in a code segment or branching to executable code in a data
    segment.
  --------------------------------------------------------------------------

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