views:

583

answers:

4

For my assembly language class, we're writing DOS programs using DPMI. Unfortunately, I don't have access to a 32-bit windows machine all the time. I do have a Debian virtual machine installed on just about every computer I do use.

I've got both DOSBox and DOSEMU installed. Is there any way that I can assemble and compile the programs in Linux rather than DOS? I'm using nasm, so I don't seem to have any problems getting it assembledin DOS format. However, I'm having trouble running it through the compiler with my C code and getting a DOS executable (using either gcc or MinGW).

Is there some way to do this or am I pretty much going to have to install all the tools under DOS?

+5  A: 

I'm not even sure if you can compile DOS applications using GCC. A long time ago there was a gcc compiler-variant called DJGPP (or something like that). I never got it working though.

The chances that you can cross-compile a GCC for DOS these days are almost zero.

I suggest you give the old Watcom Compiler a try. It's a native DOS compiler and it's DPMI implementation also works like a charm under DosBox. Interfacing with NASM compiled object files is not a problem either (I did that a couple of years)

Today the compiler has been made open source and called OpenWatcom.

http://www.openwatcom.org/index.php/Main_Page

Nils Pipenbrinck
DJGPP is what we're using to compile DOS programs in Windows, but it's a complete and total PITA to install outside Windows (even under DOS).
Jason Baker
+3  A: 

Probably the easiest way to go for you is to use the standard DOS tools for the task.

DOSBOX is a really good emulator.

Vasil
+1  A: 

BCC is in debian, and is capable of producing decent code for 8080 up to 80386. Use the -Md switch to produce an MS-DOS binary.

LiraNuna
A: 

DJGPP is ridiculously easy to install, bare minimum only three .ZIPs are needed:

1). BNU219B.ZIP (assembler, linker, librarian) 2). GCC441B.ZIP (C compiler) 3). DJDEV204.ZIP (libc, headers)

http://www.delorie.com/djgpp/getting.html

unzip *.zip -d c:\djgpp && set DJGPP=c:\djgpp\djgpp.env && path c:\djgpp\bin;%PATH%

gcc myfile.c -o myfile.exe

To produce DOS-compatible output, you'll have to either use the DOS-hosted compiler in DOSEMU (not DOSBox!! way too slow and buggy, meant for games only) or use a Linux-hosted cross compiler (DJ's site has the RPMs for that).

However, if you want 100% 16-bit code, you will have to use something else (e.g. OpenWatcom). OpenWatcom does also support Linux (beta!!) host and target (no shared libs, though, IIRC), but you may have to compile it yourself with GCC.

Rugxulo