Compiling for DOS

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiling for DOS

Felipe Monteiro de Carvalho
Hello,

I am trying to compile a very simple app (hello world kind) for DOS or
even for the Windows 98 rescue disk.

My first attempts ended up with a "This program cannot be run in DOS mode".

On the FP IDE I see many targets, but I don´t know witch one to
compile against. I see a few possible targets:

    * GO32 V2 DOS extender
    * Win32 for i386
    * WDOSX DOS extender
    * Watcom compatible DOS extenders

Witch one should I compile against?? Win32 doesn´t work and GO32
claims it can´t find system unit.

Should I recompile FPC for GO32 in order to use it? What is the
difference between it and WDOX or Watcom??

One might wonder what the reason for compiling to DOS is? I happen to
have an 486 running ibm-dos in my house and I´d like to use my own
program to test the ISA Card I recently created, instead of the DEBUG
program.

thanks,
--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Compiling for DOS

Tomas Hajny
Date sent:       Tue, 8 Nov 2005 20:16:47 -0200
From:           Felipe Monteiro de Carvalho <[hidden email]>
To:             FPC-Pascal users discussions <[hidden email]>
Subject:         [fpc-pascal] Compiling for DOS
Send reply to:   FPC-Pascal users discussions <[hidden email]>
        <mailto:[hidden email]?subject=unsubscribe>
        <mailto:[hidden email]?subject=subscribe>


Hello,

> I am trying to compile a very simple app (hello world kind) for DOS or
> even for the Windows 98 rescue disk.
>
> My first attempts ended up with a "This program cannot be run in DOS
> mode".
>
> On the FP IDE I see many targets, but I don´t know witch one to
> compile against. I see a few possible targets:
>
>     * GO32 V2 DOS extender
>     * Win32 for i386
>     * WDOSX DOS extender
>     * Watcom compatible DOS extenders
>
> Witch one should I compile against?? Win32 doesn´t work and GO32
> claims it can´t find system unit.
>
> Should I recompile FPC for GO32 in order to use it? What is the
> difference between it and WDOX or Watcom??
>
> One might wonder what the reason for compiling to DOS is? I happen to
> have an 486 running ibm-dos in my house and I´d like to use my own
> program to test the ISA Card I recently created, instead of the DEBUG
> program.

Your best choice probably is GO32v2. However, as for any other
target, you need RTL compiled for the given target, the appropriate
binutils (as and ld) and the right configuration. If you can compile
on a Win 9x/ME machine (or even machine with plain DOS), the easiest
solution (not requiring you to play with configuration, proper setup
of directories, etc.) is to download the old 1.0.10 version, make
sure you don't have any other FPC version (Win32) in PATH and use
that one. Alternatively you could overwrite that one with a 2.0.x
snapshot (for GO32v2 target). There are other options too, but these
might be more complex (I believe some of them were discussed in our
GO32v2 forum).

If you encounter any difficulties, just ask.

Hopefully a DOS (GO32v2) version of FPC 2.x gets released with one of
the next releases.

Tomas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Compiling for DOS

Felipe Monteiro de Carvalho
Hi,

> Your best choice probably is GO32v2. However, as for any other
> target, you need RTL compiled for the given target, the appropriate
> binutils (as and ld) and the right configuration.

Was FPC compiler able to create real-mode programs in the past? It
would be very important for my use, a very precise osciloscope.

Can I still use interrupts and IN / OUT assembler opcodes in protected mode?

> If you can compile
> on a Win 9x/ME machine (or even machine with plain DOS), the easiest
> solution (not requiring you to play with configuration, proper setup
> of directories, etc.) is to download the old 1.0.10 version

Thanks, I'll try that.

> Hopefully a DOS (GO32v2) version of FPC 2.x gets released with one of
> the next releases.

Maybe I can help get it released. What is missing? Code or just
someone that compiles the whole thing? I have access to a machine with
IBM DOS.

thanks again,
--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Compiling for DOS

Tomas Hajny
Date sent:       Sat, 12 Nov 2005 08:01:30 -0200
From:           Felipe Monteiro de Carvalho <[hidden email]>
To:             [hidden email],
        FPC-Pascal users discussions <[hidden email]>
Subject:         Re: [fpc-pascal] Compiling for DOS


Hi Felipe,

> > Your best choice probably is GO32v2. However, as for any other
> > target, you need RTL compiled for the given target, the appropriate
> > binutils (as and ld) and the right configuration.
>
> Was FPC compiler able to create real-mode programs in the past? It
> would be very important for my use, a very precise osciloscope.

No, FPC was being created as a protected-mode compiler from the very
beginning.


> Can I still use interrupts and IN / OUT assembler opcodes in protected
> mode?

Yes, you can, although especially interrupts might be somewhat more
complicated (depending on what you need to achieve).

For ports, you can use in/out instructions and the special array
port[] as supported by TP/BP (requires adding unit ports to uses
clause).

Regarding interrupts, there are (at least) two things to be aware of.
First, there is one interrupt vector table for the protected mode and
another table for the real mode. Calling "int xx" in your protected
mode program calls the protected mode interrupt. This will work if
interrupt handler for the protected mode version is installed - e.g.
protected mode version of interrupt 21h, i.e. DOS services, is
probably installed for most DPMI servers as far as I remember
correctly, but the same doesn't have to be true for other interrupts.
Calling the real mode version is possibly e.g. using GO32.RealIntr
(or SysRealIntr).

Second, working with pointers/memory addresses is little bit more
difficult. If you need to pass a memory block to some interrupt (e.g.
a buffer to be filled with some information by the interrupt), you
need to allocate this memory block within the first MB of your
address space (real-mode code cannot access/address more), and you
have to remember that this memory block is addressed different way
while under real-mode (16-bit segment and offset must be passed to
real-mode code) and when accessing it from protected-mode (32-bit
flat address is used). Functions Global_Dos_Alloc and Global_Dos_Free
provided in unit Go32 are your friends here.


> > If you can compile
> > on a Win 9x/ME machine (or even machine with plain DOS), the easiest
> > solution (not requiring you to play with configuration, proper setup
> > of directories, etc.) is to download the old 1.0.10 version
>
> Thanks, I'll try that.
>
> > Hopefully a DOS (GO32v2) version of FPC 2.x gets released with one
> > of the next releases.
>
> Maybe I can help get it released. What is missing? Code or just
> someone that compiles the whole thing? I have access to a machine with
> IBM DOS.

Machine is not such a big problem (although our makefiles don't work
under plain DOS, but require some LFN-capable system - it isn't a
problem of the compiler, that one works under plain DOS without
problems). There have been some bugs which prevented us from having
version 2.0.0 released for GO32v2 target too. The most important
issues should be hopefully fixed now, but some smaller ones still
remain. Anybody able to help with debugging the remaining issues is
certainly welcome. ;-)

Tomas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Compiling for DOS

Lee, John
In reply to this post by Felipe Monteiro de Carvalho
Felipe, I use Win ME to make go32v2, v2.0.3 and v2.1.1 so this should work ok. I've also used win9se in the past.  

I produce daily snapshots of these. See ftp.freepascal.org\ snapshots\v20 & v21, so you can download these & try them out.

Regards John    

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]]On Behalf Of
> Tomas Hajny
> Sent: 12 November 2005 18:19
> To: FPC-Pascal users discussions
> Subject: Re: [fpc-pascal] Compiling for DOS
>
>
> Date sent:       Sat, 12 Nov 2005 08:01:30 -0200
> From:           Felipe Monteiro de Carvalho
> <[hidden email]>
> To:             [hidden email],
> FPC-Pascal users discussions <[hidden email]>
> Subject:         Re: [fpc-pascal] Compiling for DOS
>
>
> Hi Felipe,
>
> > > Your best choice probably is GO32v2. However, as for any other
> > > target, you need RTL compiled for the given target, the
> appropriate
> > > binutils (as and ld) and the right configuration.
> >
> > Was FPC compiler able to create real-mode programs in the past? It
> > would be very important for my use, a very precise osciloscope.
>
> No, FPC was being created as a protected-mode compiler from the very
> beginning.
>
>
> > Can I still use interrupts and IN / OUT assembler opcodes
> in protected
> > mode?
>
> Yes, you can, although especially interrupts might be somewhat more
> complicated (depending on what you need to achieve).
>
> For ports, you can use in/out instructions and the special array
> port[] as supported by TP/BP (requires adding unit ports to uses
> clause).
>
> Regarding interrupts, there are (at least) two things to be aware of.
> First, there is one interrupt vector table for the protected mode and
> another table for the real mode. Calling "int xx" in your protected
> mode program calls the protected mode interrupt. This will work if
> interrupt handler for the protected mode version is installed - e.g.
> protected mode version of interrupt 21h, i.e. DOS services, is
> probably installed for most DPMI servers as far as I remember
> correctly, but the same doesn't have to be true for other interrupts.
> Calling the real mode version is possibly e.g. using GO32.RealIntr
> (or SysRealIntr).
>
> Second, working with pointers/memory addresses is little bit more
> difficult. If you need to pass a memory block to some interrupt (e.g.
> a buffer to be filled with some information by the interrupt), you
> need to allocate this memory block within the first MB of your
> address space (real-mode code cannot access/address more), and you
> have to remember that this memory block is addressed different way
> while under real-mode (16-bit segment and offset must be passed to
> real-mode code) and when accessing it from protected-mode (32-bit
> flat address is used). Functions Global_Dos_Alloc and Global_Dos_Free
> provided in unit Go32 are your friends here.
>
>
> > > If you can compile
> > > on a Win 9x/ME machine (or even machine with plain DOS),
> the easiest
> > > solution (not requiring you to play with configuration,
> proper setup
> > > of directories, etc.) is to download the old 1.0.10 version
> >
> > Thanks, I'll try that.
> >
> > > Hopefully a DOS (GO32v2) version of FPC 2.x gets released with one
> > > of the next releases.
> >
> > Maybe I can help get it released. What is missing? Code or just
> > someone that compiles the whole thing? I have access to a
> machine with
> > IBM DOS.
>
> Machine is not such a big problem (although our makefiles don't work
> under plain DOS, but require some LFN-capable system - it isn't a
> problem of the compiler, that one works under plain DOS without
> problems). There have been some bugs which prevented us from having
> version 2.0.0 released for GO32v2 target too. The most important
> issues should be hopefully fixed now, but some smaller ones still
> remain. Anybody able to help with debugging the remaining issues is
> certainly welcome. ;-)
>
> Tomas
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Compiling for DOS

Felipe Monteiro de Carvalho
In reply to this post by Tomas Hajny
Hi,

> No, FPC was being created as a protected-mode compiler from the very
> beginning.

Is it very different to compile for protect-mode DOS and real-mode DOS?

Interesting that FPC was based on TP 7, but TP 7 only compiled for real-mode.

> Yes, you can, although especially interrupts might be somewhat more
> complicated (depending on what you need to achieve).

Let´s say write my own interrupt to communicate as fast as possible
with a time sensitive hardware. I just wonder if a protected-mode
could make this problematic....

Time sensitive hardware usually goes for real-mode solutions or very
good drivers, or at least this is what I read.

> For ports, you can use in/out instructions and the special array
> port[] as supported by TP/BP (requires adding unit ports to uses
> clause).

I am already using them at this time =) ... just on TP 7

As the main part of the program is a Lazarus project it would be nice
to have Free Pascal compiling it.

> This will work if
> interrupt handler for the protected mode version is installed - e.g.
> protected mode version of interrupt 21h, i.e. DOS services, is
> probably installed for most DPMI servers as far as I remember
> correctly, but the same doesn't have to be true for other interrupts.
> Calling the real mode version is possibly e.g. using GO32.RealIntr
> (or SysRealIntr).

Interesting. What is DPMI?

> and you
> have to remember that this memory block is addressed different way
> while under real-mode (16-bit segment and offset must be passed to
> real-mode code) and when accessing it from protected-mode (32-bit
> flat address is used). Functions Global_Dos_Alloc and Global_Dos_Free
> provided in unit Go32 are your friends here.

thanks for the hints,

--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Compiling for DOS

Felipe Monteiro de Carvalho
In reply to this post by Lee, John
On 11/12/05, Lee, John <[hidden email]> wrote:
> Felipe, I use Win ME to make go32v2, v2.0.3 and v2.1.1 so this should work ok. I've also used win9se in the past.

thanks, I´ll try them.
--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Compiling for DOS

Jonas Maebe-2
In reply to this post by Felipe Monteiro de Carvalho

On 12 Nov 2005, at 20:47, Felipe Monteiro de Carvalho wrote:

>> No, FPC was being created as a protected-mode compiler from the very
>> beginning.
>
> Is it very different to compile for protect-mode DOS and real-mode  
> DOS?

Yes. Real-mode Dos is generally 16 bit (although 32 bit real mode is  
possible as well, but that does not work as soon as emm386, qemm386  
etc is used, or if you have a Dos box under any Windows flavour.

FPC does not contain a 80x86 16 bit code generator (nor a 32 bit Dos  
real mode RTL).

> Interesting that FPC was based on TP 7, but TP 7 only compiled for  
> real-mode.

Only the language was based on TP7. The code of the compiler and RTL  
was written from scratch. And the main reason to start FPC was  
because TP was only a 16 bit real mode compiler.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal