The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: sharpe on March 20, 2005, 05:05:24 PM

Title: COM programmes
Post by: sharpe on March 20, 2005, 05:05:24 PM
Hello,

I am wondering how to write COM programmes. I am playing around with some things which require me to write a small COM (*.COM) programme. what does a *.COM programme look like when compared with an *.EXE, and how is one compiled? I have masm32 installed and running.

Thanks in advance!
Title: Re: COM programmes
Post by: AeroASM on March 20, 2005, 08:40:48 PM
MASM32 is used to create 32-bit applications; the exe is in PE format and is native to Win95 and above.
16-bit applications cannot run in Windows; they are run in a virtual machine which emulates DOS.

.com programs are 16-bit; to make them you can use the assembler (ml.exe) in masm32, but you need the Link version 5.63 (16-bit linker) in order to make a 16-bit application.

I am not sure exactly what the differences are between .com and .exe, but in a nutshell it is this:

1. 16-bit .com files and 16-bit .exe files are very similar; they have to run a a virtual machine and both need Link 5.63
2. 32-bit applications (.exe only) are very different from 16-bit applications.
Title: Re: COM programmes
Post by: pbrennick on March 20, 2005, 09:04:42 PM
In a .com file, everything, code, data and stack are all in the same segment which means a come file cannot exceed 64k.

Paul
Title: Re: COM programmes
Post by: mnemonic on March 21, 2005, 04:09:35 AM
Here (http://www.groovyweb.uklinux.net/index.php?page_name=assembly%20language%20how%20to) you will find a introduction to assembler where among other topics the one you're asking for is explained in detail.
Just have a look.

Regards
Title: Re: COM programmes
Post by: MichaelW on March 21, 2005, 07:19:15 AM
The attachment includes minimal source frameworks for COM and EXE files, along with batch files that can be used to assemble and link each framework, and generate a listing file and a map file. Both frameworks use the simplified segment directives. You can produce exactly the same program structure using full segment definitions, but considerably more effort is required.

You can download a 16-bit linker here:

http://spiff.tripnet.se/~iczelion/download.html

The download is a self-extracting archive that includes the linker. Take care to avoid overwriting the 32-bit linker because both are named link.exe. To differentiate it from the 32-bit linker I normally rename the 16-bit linker to link16.exe.

I use the ML from the MASM32 package for 16-bit programs, but to avoid confusion I create a separate folder for 16-bit programs, and copy ML.EXE, ML.ERR, and the 16-bit linker to it. The included batch files assume such an arrangement.

The attachment also includes a batch file that copies the help screens for ML.EXE and link16.exe to text files so the information can be easily referenced.


[attachment deleted by admin]
Title: Re: COM programmes
Post by: sharpe on March 21, 2005, 09:56:02 AM
Thanks super.
Thank you all for your wise words. All is running now.

/sharpe
Title: Re: COM programmes
Post by: Vortex on March 21, 2005, 11:06:12 AM
Hi sharpe,

Welcome to the forum.

Basically, COM files are pure image files beginning at 100h. The max file size for a COM is 64Kb. On the other hand, executables have specific headers which is different in the 16-bit and 32-bit system. 16-bit DOS executables have generally a stack,data and code segment at the minimum level.