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!
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.
In a .com file, everything, code, data and stack are all in the same segment which means a come file cannot exceed 64k.
Paul
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
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]
Thanks super.
Thank you all for your wise words. All is running now.
/sharpe
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.