DPMI32: a DOS target platform for Virtual Pascal.

Model description

The created programs run on most current DOS versions (3.3+) or DOS emulations and require an 386 or better processor and coprocessor or emulator. Memory mode is flat 4 GB where Mem[0] is the first byte of of Memory of the machine or session and for example the text video memory starts with Mem[$b8000].
Other models exist where nil^ is not a valid memory loction, but this model was choosen because of its simplicity and easy programming.

Useable DOS-Extenders are:

Most DOS-Extenders support following memory interfaces: Independent of underlying memory interface the program can always use DPMI-services (that gave it the name). Some extenders can configured to provide virtual memory by swap files.

Implemented Units

EXE-Format, Linker, EXE-Packers

I wanted to use the internal linker from VP because of its many benefits. The supported DOS-Extenders know the LE-EXE-Format. The internal linker produces the LX-Exe (OS/2) and PE-Exe (Win32) format. LX would be better because LX is LE improved for OS/2 2.0, but the linker does not generate fixup records for programs. I wrote PE2LE. PE2LE also can do other things like binding the selected DOS-Extender into the generated executable.
To produce the now in Win32 format expected resources i created a RC1 program that uses OS/2 RC and then converts the result.

If you have finished and think about distributing your DPMI32-program you can compress it with an "generic" LE-compressor. On "real" operaing systems compressing executables has the disadvantage to that it prevents to share shareable code and constant segemnts between differen processes (Exepack 1/2 (LxLite) is an exception because the decompression is integrated into the OS). But for DOS (and DPMI32-programs are DOS-programs) this is not a problem. It is even recommended to use special executable compressors for LE because they compress better than most file archivers.

Description of debug modules

To debug a DPMI32-program from IDE i wrote unit deb_link. It is embedded into your compiled program and connects with debug-dll VpDbgDll.DLL. This dll is loaded by the IDE and communicates with it by the documented ODAPI interface.
In OS/2 the communication is done via two one-way pipes: Pipe one transmits commands from VpDbgDll like "i want 4 bytes at memory location y !", on the second deb_link sends the results like "i could read them, 4 bytes". This communication is fast and does not cost much resources because waiting any any end for more data blocks the waiting process. For Windows i could not found a similiar way, it is done by using 2 files in your filesystem. This does not block waiting processes and thus the whole communication is very slow.
Normally the initialisation code of deb_link would run after the initialisation code of the System unit and it would not possible to debug the initialisation of the runtime library. To change this PE2LE sets the entrypoint to deb_link if it find it in your program. Deb_link can not make calls to the runtime library anyway because you could not set breakpoints int the RTL otherwise.

execution order under OS/2:

In Windows things run similar, but here VPDDID.SYS is replaced by VPDDID.EXE and can not allocate memory at $00401000, auto_os2.bat is not executed.
To debug DPMI32-programs you have to insert deb_link into the uses clause. But your final program does not may contain deb_link, i recommend the following:

    program test;

    uses
      {$IfDef DPMI32}
        {$IfDef debug}
          deb_link,
        {$EndIf}
      {$EndIf}
      Crt,
      ....

Then put debug into conditional symbol entry in options/compiler dialog.

Help for DPMI32

After installing D32 you will find documentation of additional utils and units in VP online help. Source for this help is included in \vp21\source\d32\hilfe .
In \vp21\examples\d32 are some samples to demonstate some DPMI32 units.
A good programming documentation that also covers DPMI is Ralf Brown`s Interrupt List.

Comparison between BP 7 Real mode/DPMI 16

Porting of DOS-functions from BP 7 sources to DPMI32

Installation of DPMI32 into Virtual Pascal

  1. Extract the archive with "arj x -y dpmi32_lfs_279.arj D:\vp21\" into the base directory of Virtual Pascal, here D:\VP21.
    Arj for DOS, OS/2 or Windows will needed.
    (alternative zip/rar packages exist)
  2. run applydif.bat. This will configure ini and batch files for your directory structure and updates classes.pas+sysutils.pas.
  3. change to source\rtl subdir and launch _all.bat or _all.cmd, depending on host OS.
    This will recompile the runtime library and system unit for all platforms, and may take some amount of time...

Functions to implement

On my work/wish list are:

Problem Solution

If you find a problem with DPMI32 and want contribute to its solution please send me a following details:

Motivation for DPMI32

The biggest program i wrote and that had cost me much of my spare time is Typ:
a filetype/ compiler/ packer/ .. -recognition, archive,.. lister program.
The project started 1994 from a program that had to react better to filename extenstions in Norton Commander than the internal function (.mod: Modula-2 source or Amiga module ?).
The program grow in size and i improved id.
At the time i tarted using OS/2 i wanted to have a OS/2 port and found the beta version of Virtual Pascal...
With the development of Virtual Pascal 2.0 there was added the Win32 target.
I do not have much use of it but it made VP more portable by introducing OS dependent and independent layers of the runtime library.
At about this time i got problems with debugging Typ in BP: the program went to big !
So i created a DOS target for VP.

Screen with Ratrace excample