Turbo Pascal version 1.0 - Memory Management, CP/M-80

Posted by on in Blogs
From the Turbo Pascal manual:

The following diagrams illustrate the contents of memory at different stages of working with the TURBO system.

Compilation in Memory - During compulation of a program in memory, the memory is mapped as follows:

  • 0000

  •   CP/M and run-time workspace

  •   Pascal Library

  •   Turbo interface, editor, and compiler

  •   Error Messages (optional - when you start TURBO.COM it asks whether you want to load them or not)

  •   Source text

  •   Object code - growing upward from the end of the source text

  •   Symbol table - growing downward from an address 1k ($400 bytes) below the logical top of memory

  •   CPU stack - growing downward from the logical top of memory

  •   CP/M operating system

  • HighMem


Compilation to Disk - During compulation to a .COM or .CHN file, the memory looks much as during compilation in memory except that generated object code does not reside in memory but is written to a disk file. Also, the code starts at a lower address (right after the Pascal library instead of after the source text). Compilation of much larger programs is thus possible in this mode.

  • 0000

  •   CP/M and run-time workspace

  •   Pascal Library

  •   Turbo interface, editor, and compiler

  •   Error Messages (optional - when you start TURBO.COM it asks whether you want to load them or not)

  •   Source text

  •   Symbol table - growing downward from an address 1k ($400 bytes) below the logical top of memory

  •   CPU stack - growing downward from the logical top of memory

  •   CP/M operating system

  • HighMem


Execution in Memory - When a program is executed in direct - or memory - mode, the memory is mapped as follows. When a program is compiled, the end of the object code is known. The maximum memory size is BDOS minus one. Program variables are stored from this address and downwards. The end of the variables is the 'top of free memory' which is the initial value of the CPU stack pointer. The CPU stack grows downwards from here towards the position of the recursion stack pointer $400 bytes lower than the stack pointer. The recursion stack grows from here downward towards the heap.

  • 0000

  •   CP/M and run-time workspace

  •   Pascal Library

  •   Turbo interface, editor, and compiler

  •   Error Messages (optional - when you start TURBO.COM it asks whether you want to load them or not)

  •   Source text

  •   Object code

  •   Heap growing upward

  •   Recursion stack growing downward

  •   CPU stack - growing downward from the logical top of memory

  •   Program variables

  •   CP/M operating system

  • HighMem


Execution of a Program file - When a program file is executed, the memory is mapped as follows. The map resembles the previous, except for the absence of the TURBO interface, editor, and compiler (and possible error messages) and of the source text. The default program start address is the first free byte after the Pascal runtime library. This value may be manipulated with the 'Start address command' of the compiler Options menu, e.g. to create space for absolute variables and/or external procedures between the library and the code. The maximum memory size is BDOS minus one, and the default value is determined by the BDOS location on the computer. If programs are to be translated for other systems, care should be taken to avoid collision with the BDOS. Notice that the default end address setting is approximately 700 to 1000 bytes lower than maxumum memory. This is to allow space for the loader which resides just below BDOS when .COM files are run or executed from the TURBO system. This loader restores the TURBO editor, compiler, and possible error messages when the program finishes and thus returns control to the TURBO system.

  • 0000

  •   CP/M and run-time workspace

  •   Pascal Library

  •   Object code

  •   Heap growing upward

  •   Recursion stack growing downward

  •   CPU stack - growing downward from the logical top of memory

  •   Program variables

  •   CP/M operating system

  • HighMem



About
Gold User, Rank: 1, Points: 2466
David Intersimone (known to many as David I.) is a passionate and innovative software industry veteran-often referred to as a developer icon-who extols and educates the world on Embarcadero developer tools. He shares his visions as an active member of the industry speaking circuit and is tapped as an expert source by the media. He is a long-standing champion of architects, developers and database professionals and works to ensure that their needs are folded into Embarcadero's strategic product plans. David holds a bachelor's degree in computer science from California Polytechnic State University at San Luis Obispo, California.

Comments

Check out more tips and tricks in this development video: