[comp.lang.pascal] Writing a device driver in TP

dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (05/29/91)

I've heard (and said!) repeatedly that it's impossible to write a DOS device
driver in Turbo Pascal.  Not true - I've written a simple one entirely in
TP 6, and uploaded it to garbo.uwasa.fi (TPDEV.ZIP).  It would be harder,
but probably possible, to do the same thing in earlier versions of TP.
I imagine it would require careful byte counting, external assembler code,
patching, or some other trick I can't think of.  TP 6 has the inline
assembler, assembler procedures, and allows constants to be initialized with
the address of code, so it was relatively easy there.

Take a look at it.   It makes prototyping a device driver much easier than
writing it from scratch in assembler.

One limitation:  it produces .EXE format drivers.  I asked the other day about
limitations on these, and got two responses:

 - They work in MSDOS, but not PCDOS, because the .EXE loader is part of
   COMMAND.COM in PCDOS.
 - They only work in version 3 or higher.

Thanks to those who responded!  I can confirm that the .EXE format is
fine in MSDOS 3.2, but haven't tested it anywhere else.

Duncan Murdoch
dmurdoch@watstat.waterloo.edu

valley@gsbsun.uchicago.edu (Doug Dougherty) (05/30/91)

This has nothing to do with the original post, but...

dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes:

> - They [.EXE format device drivers] work in MSDOS, but not PCDOS,
	because the .EXE loader is part of COMMAND.COM in PCDOS.
really??? ---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> - They only work in version 3 or higher.

That's interesting.  Does this mean that you can't exec() a .EXE file
directly (from another program) in PC/DOS?  (I.e., that you would have
to run it via system() ?)
--

	(Another fine mess brought to you by valley@gsbsun.uchicago.edu)

terra@diku.dk (Morten Welinder) (06/06/91)

valley@gsbsun.uchicago.edu (Doug Dougherty) writes:

>This has nothing to do with the original post, but...

>dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes:

>> - They [.EXE format device drivers] work in MSDOS, but not PCDOS,
>	because the .EXE loader is part of COMMAND.COM in PCDOS.
>really??? ---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

My manual says so too! (MSDOS 3.1 technical ref.)


>> - They only work in version 3 or higher.

>That's interesting.  Does this mean that you can't exec() a .EXE file
>directly (from another program) in PC/DOS?  (I.e., that you would have
>to run it via system() ?)
>--

No. It is only a problem when writing device drivers, since they are loaded
before the first instance of command.com.

Morten 'Sally' Welinder
terra@rimfaxe.diku.dk