[comp.sys.ibm.pc] EXE And COM files

i14@nikhefh.hep.nl (Martin Los) (12/13/88)

Could anyone help me with these problems?
1)What is the general format of an EXE file?
2)What is the general format of a COM file?
3)Is it possible to add a portion of ML(machine language)code to an EXE or
 COM file??

Thanks in advance,
    
                  Martin 'Syntax' Los
               at i14@nikhefh.hep.nl
                                

brown@nicmad.UUCP (Vidiot (Vid-e-it)) (12/15/88)

In article <596@nikhefh.hep.nl> i14@nikhefh.hep.nl (Martin Los) writes:
<Could anyone help me with these problems?
<1)What is the general format of an EXE file?

These are re-locatable programs.  The code is NOT directly executable.  If
you use the DOS debug command, it will LOOK like it is, because the debug
program does the relocating when it sees that it is a .EXE program.  To look
at the code BEFORE relocation takes place, rename the program and then look
at it with DEBUG (the only way to modify .EXE files).

<2)What is the general format of a COM file?

These are direct machine language programs that must fit within a 64K page
area.  That is why they are never longer than 64K.  These can be looked at
directly with debug, executed and changed within debug.

<3)Is it possible to add a portion of ML(machine language)code to an EXE or
< COM file??

.COM files can be easily modified with debug (or other tools), but .EXE files
are tough.  Don't get me wrong, they can be modified.  But because they are
re-locatable, you must really know what you are doing.
-- 
	       harvard-\	 att--\
Vidiot            ucbvax!uwvax!astroatc!nicmad!brown
	       rutgers-/      decvax--/
	ARPA/INTERNET: brown%nicmad.UUCP@spool.cs.wisc.edu

hermit@shockeye.UUCP (Mark Buda) (12/16/88)

In article <596@nikhefh.hep.nl> i14@nikhefh.hep.nl (Martin Los) writes:
>Could anyone help me with these problems?
>1)What is the general format of an EXE file?
>2)What is the general format of a COM file?
>3)Is it possible to add a portion of ML(machine language)code to an EXE or
> COM file??

I'm not sure if I know what I'm talking about, but a COM file doesn't have
a format. It is just an image of the program, whose entry point must be at
an offset of zero.

What I'd like to know is what is the format of a Microsoft Windows
"extended executable format" file.

>Thanks in advance,

Me too.
-- 
Mark Buda / Smart UUCP: hermit@shockeye.uucp / Phone(work):(717)299-5189
Dumb UUCP: ...rutgers!bpa!vu-vlsi!devon!shockeye!hermit
I hate this $%$@%!$@%!@$%@#$@!% machine.
"A little suction does wonders." - Gary Collins

pozar@hoptoad.uucp (Tim Pozar) (12/19/88)

In article <250@shockeye.UUCP> hermit@shockeye.UUCP (Mark Buda) writes:
>I'm not sure if I know what I'm talking about, but a COM file doesn't have
>a format. It is just an image of the program, whose entry point must be at
>an offset of zero.

   Not quite.  .COM programmes start at an offset of 100h.
		  Tim

-- 
 ...sun!hoptoad!\                                     Tim Pozar
                 >fidogate!pozar               Fido:  1:125/406
  ...lll-winken!/                            PaBell:  (415) 788-3904
       USNail:  KKSF / 77 Maiden Lane /  San Francisco CA 94108

smvorkoetter@watmum.waterloo.edu (Stefan M. Vorkoetter) (12/19/88)

In article <6078@hoptoad.uucp> pozar@hoptoad.UUCP (Tim Pozar) writes:
->In article <250@shockeye.UUCP> hermit@shockeye.UUCP (Mark Buda) writes:
->->I'm not sure if I know what I'm talking about, but a COM file doesn't have
->->a format. It is just an image of the program, whose entry point must be at
->->an offset of zero.
->
->   Not quite.  .COM programmes start at an offset of 100h.
->		  Tim

Well, they are loaded at an offset of 100h in the code segment, but they
start at an offset of zero in the FILE.  And the entry point is right at
the beginning.

Stefan Vorkoetter
(smvorkoetter@watmum)

rogerson@PEDEV.Columbia.NCR.COM (rogerson) (12/19/88)

In article <250@shockeye.UUCP> hermit@shockeye.UUCP (Mark Buda) writes:
>What I'd like to know is what is the format of a Microsoft Windows
>"extended executable format" file.

	A recent issue of PC Tech Journal (I think) had an article on the
	format of the EXE file for OS/2.  This format is the same for
	Microsoft Windows.  The only real information missing is the format
	for the resource table.  NOTE:  There are errors in the documentation
	of the Windows SDK 2.1 manuals concerning the format of the EXE header.
	I do not have the current format with me here at work, but will try to
	bring it later.

	Bitte
	-----Dale
		Rogerson-----

hollen@spot.megatek.uucp (Dion Hollenbeck) (12/20/88)

From article <7386@watcgl.waterloo.edu>, by smvorkoetter@watmum.waterloo.edu (Stefan M. Vorkoetter):
> In article <6078@hoptoad.uucp> pozar@hoptoad.UUCP (Tim Pozar) writes:
> >In article <250@shockeye.UUCP> hermit@shockeye.UUCP (Mark Buda) writes:
> >>I'm not sure if I know what I'm talking about, but a COM file doesn't have
> >>a format. It is just an image of the program, whose entry point must be at
> >>an offset of zero.
> >
> >   Not quite.  .COM programmes start at an offset of 100h.
> >		  Tim
> 
> Well, they are loaded at an offset of 100h in the code segment, but they
> start at an offset of zero in the FILE.  And the entry point is right at
> the beginning.
> 
> Stefan Vorkoetter
> (smvorkoetter@watmum)
Everybody above is mostly right.  To clear things up, the assembly source
which generates a .COM program must ORG the first instruction at
100H.  This means that an absolute JMP instruction to the second instruction
of the code (assuming the first is 3 bytes long) would be JMP 103H.  Yes,
the beginning of the file (offset 0) is the beginning of the code.
Also, a  .COM program can have only one segment in which the CODE, DATA
and STACK are all kept.  If the program knows about unused memory, it
can change around the segments once it starts running (like moving the
stack).  Com programs load faster because the loader does not have to
resolve addresses when it is laying down the memory image of the 
program since everything is in one segment and all references are
single segment relative.  Also, at the beginning of the program, the
loader initializes all the segment registers to one value.



	Dion Hollenbeck             (619) 455-5590 x2814
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121

                                seismo!s3sun!megatek!hollen
                                ames!scubed/