Link to home
Start Free TrialLog in
Avatar of r_bal
r_bal

asked on

"com" vs "exe" files

What is the difference between .com and .exe files
Avatar of r_bal
r_bal

ASKER

Adjusted points to 50
ASKER CERTIFIED SOLUTION
Avatar of roverm
roverm
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Both Com and Exe are executable files.

Whereas  a com file (Command File) has size restriction  compared to an Exe (Binary File ) file.

If you r having 2 file of same name with .Com and .Exe extensions

the sequence of execution (while giving the file name without Extension) as follows
1. .Com
2. .Exe

It means .. it will first search for a Com file and then for a Exe file if you are not mentioning the Extionsion.

Hope its clear.

Kumar

This is from the "olden" days, but a .com executable has no relocatable segments where a .exe can have any number of them.  SO, for a .com the loader doesn't have to worry about where the stack segment is or the data segment or the code segment is (obviously this is Intel stuff).  I have never analyzed a .exe image that didn't have atleast 1 relocatable segment.
    I must agree with GlennDean that is old stuff, but i guess I am old as well.
      Them Com file style was made up to be compatibel with the previous operating system wide accepted, the CP/M(CP/M used to run on Apple II, Radio Shack TRS-80).
      The CP/M was based upon the microprocessor Z-80 from Zilog (it use to run at 4MHZ).
      The CP/M reserved 256 bytes of inicial program memory to interrupt vetors to the hardware and to the software (like DOS int21 for exemplo).
      So the COM file does the same and it always start at address 100H, and to be compatible code,data and stack segments are set to the same value at entering.
      The EXE file is the first native 16 bits 8086 file format, so you can have several segments.
      The first 512 bytes of an EXE file is the PSP(Programm Segment Prefix). which have several information about the program, including the entry point that may vary, you tell the compiler the name of the main procedure and it does the job.
      You may never heard about CP/M and this may be old stuff, but ug.. CP/M standards still lives inside WINDOWS2000.
Edio:
   I didn't know the loader always loaded a .com at 100H, but thanxs for the info.
   The code/data/stack segment registers are all the same in a .com file.  When I use to write .com programs in assembly (along time ago "in a galaxy far far away") we would almost always mix data and code together!  It was quite common for the first instruction of the .com file to do a jump pass the data you needed.
   Like Edio mentioned, the PSP contains how many relocatable segments exists for a .com/.exe.  For a .com it must be 0.  
   Glenn
   
Avatar of r_bal

ASKER

Thanx for the explanation.