[fpc-pascal] FPC in DOS environment

Tomas Hajny XHajT03 at mbox.vol.cz
Thu Jan 11 10:38:48 CET 2007


Daniel Franzini wrote:


Hi Daniel,

> i'm trying to use fpc in a old DOS environment by using FreeDOS inside
> Virtual PC (guess i should be using vmware)

I've had difficulties running FPC apps (probably including the compiler
itself) under FreeDOS in the past (whereas it works properly with other
DOS implementations like MS-DOS, IBM PC DOS and DR-DOS/Novell DOS). Things
might have improved since then, though.


> the problem is that i have some low-level code which i would like to port
> to
> fpc. FreeDOS came with fpc 2.0.2 which i think is suitable for my needs.
 .
 .
> the strange thing is that if i call fpc without parameters the (huge)
> usage
> shows up correctly...is fpc for go32v2 a pmode app? which extender do you
> recommend me to use?

GO32v2 is a protected mode application, indeed - specifically, it's using
DPMI (DOS Protected Mode Interface). No special extender is needed if you
already have DPMI host available (up and running). Some DOS
implementations already include this such DPMI host, similarly DPMI host
is provided for DOS applications running under Win 3.x, Win32 platforms,
OS/2, etc. If you run GO32v2 applications and no DPMI host is running, the
loader/stub (linked into the compiled executable) tries to locate (using
standard search rules - current directory and then using %PATH%) and
launch CWSDPMI.EXE first (thus starting a DPMI host itself).


> 2.) i have some questions regarding pmode programming with fpc since i
> never
> used go32v2. with cwsdpmi, one compiles and links, getting an exe and this
> exe should be put in the same folder of cwsdpmi.exe. what's the general
> procedure for go32v2?

I guess the description above should be sufficient. Alternatively, you can
bind the DPMI host directly into the executable (using tools provided
within the standard CWSDPMI package), but this is of limited use in
general (only reasonable if having single GO32v2 executable on a DOS
machine with no DPMI host).


> 3.) in other machine i tried and compiled the code but got some strange
> results (i can post as soon as a i get home and reach that machine). here
> is
> the code:
 .
 .
> function DiskRead(drive: byte; sector, n_sectors: integer; var buffer:
> buf):
> integer;
> begin
>         inline($55/
 .
 .
> {this assembly code does nothing more than saving correct stuff, executes
> DOS}
 .
 .

Surely, this inline stuff needs to be disassembled and ported to a 32-bit
protected mode environment in order to make it to work properly with FPC.


> this code compiles fine with tp5.5 (altough the window function does not
> work)...what is the correct way to make such a thing in fpc?!

Rewrite it in proper 32-bit assembler targetted for a protected mode
environment. I guess you should be able to find some information available
on Internet regarding what needs to be changed and how, but it isn't that
simple to be described here (especially with functions requiring a memory
buffer shared between real mode and protected mode code like with your
disk read/write functions).


> how to mix assembly with fpc in the same procedure/function? i tried but
> it
> complained about the labels

I guess that it's easier to discuss the particular example you tried
directly if you post it here.

Tomas




More information about the fpc-pascal mailing list