Previous: 2.1. Implementation Issues To the Table of Contents Next: 2.1.2. Calling Conventions
2.1. Implementation Issues Table of Contents 2.1.2. Calling Conventions

- 2.1.1. -
Table of Contents
2. TMT Pascal Language Description
2.1. Implementation Issues
2.1.1. Memory Organization


2.1.1. Memory Organization


The TMT Pascal compiler uses the TMTSTUB (based on WDOSX) and PMWSTUB (based on PMODE/W) extenders for a protected-mode program.

The segment registers are not used in protected mode. Instead all address space is separated into 4Kb pages.

You do not need to add a special _zero variable to get access to the physical addresses.

For example:
procedure clr_video(filler: char);
var
  i: Integer;

begin
  for i := 0 to 80 * 25 - 1 do
    Mem[$B8000 + i * 2] := filler;
end;
This procedure fills the video memory of the VGA adapter with the filler symbol. Note that the linear address $B8000 is used as the physical address - not the segment address $B800.

Some another special variables are described in the SYSTEM unit. The _psp variable contains the logical 32-bit address of the PSP of the program, and the _environ variable contains the environment address.

Although you can access the interrupt vectors by using this method, we do not suggest doing this.

Also keep in mind that MS-DOS interrupt handlers use memory addresses in the 1st Mb of physical memory while your program and its data are loaded beyond the 1st Mb. The TMTSTUB intercepts and correctly handles some, but not all, calls to MS-DOS. Thus, if you are using Intr or MsDos calls, or call MS-DOS from the assembler, you will need to modify the code.

Absolute memory addressing Mem, MemW, MemL, and MemD pseudo-arrays may be used in BP-compatible manner:
var
  x: type absolute seg:offs Mem[seg:offs];
Here the effective address is computed as seg*16+offs. The Ptr(seg, offs) function works similarly. The Seg(v) function still always returns 0.

These new functions should substantially simplify the conversion of the programs that use absolute addressing.

An example of using these functions can be found in file
TMT.5\SAMPLES\MSDOS\FLAME\FLAME.PAS

See also:
PMODE/W API


Previous: 2.1. Implementation Issues To the Table of Contents Next: 2.1.2. Calling Conventions
2.1. Implementation Issues Table of Contents 2.1.2. Calling Conventions

- 2.1.1. -