flat assembler
Message board for the users of flat assembler.

Index > Main > What is a .com file?

Author
Thread Post new topic Reply to topic
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 27 Jan 2010, 22:07
is it just like a DOS .exe but with no header? i have heard it is emulated, is that true?

whats the real difference of use a DOS .exe or a .com file?

Thanks in advance.

_________________
Sorry if bad english.
Post 27 Jan 2010, 22:07
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 27 Jan 2010, 22:37
There is no header in .com files, but one sort of gets placed before it by DOS.

http://en.wikipedia.org/wiki/Program_Segment_Prefix

That's why .com files need "org 100h" at the beginning of them. DOS creates the PSP from 0-FF and puts the program at 100h.



EDIT: http://en.wikipedia.org/wiki/DOS_MZ_executable

Quote:

The MZ DOS executable file is newer than the COM executable format and differs from it. The DOS executable header contains relocation information, which allows multiple segments to be loaded at arbitrary memory addresses, and it supports executables larger than 64 KiB, however the format still requires relatively low memory limits. These limits were later bypassed using DOS extenders.

_________________
----> * <---- My star, won HERE


Last edited by windwakr on 28 Jan 2010, 03:05; edited 2 times in total
Post 27 Jan 2010, 22:37
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 28 Jan 2010, 01:42
The answer to your question is difficult to answer. What windwakr has given you is correct, but it isn't the whole story. As you can imagine, the reason executable file formats have changed over time due to the needs and pressures of the times. The basics of a COM file is that they were developed for a platform with a simple (relatively compared to especially an i7) architecture with very little memory. And speaking of realative, all memory associations where relative to one segment, so the COM got loaded into say 0900:0100h and the PSP was generated in association to where the OS loaded it (PSP is a basic linked listing of chained programs BTW) and this is why your limitation with COM files FEFFh (0100h less) and within that your stack and data would reside. That doesn't mean you couldn't develop a COM file that uses multiple segments, but their initial intention was not. I've written many COM files that can use multiple segments, but if the OS is called upon to load more code after your COM you risk it being overwritten unless you do some OS modifying within the COM itself. Smile EXE files where a progression towards using more of the memory available. The OS manages EXE files differently based on the programs needs which are within the EXE's header. Microsoft describes it with a great level of detail here: http://support.microsoft.com/kb/65122

I hope this adds to your understanding.
Post 28 Jan 2010, 01:42
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1905
DOS386 28 Jan 2010, 06:17
> What is a .com file?

A raw 16-bit real mode DOS executable for 8086 or compatible CPU with no header, limited to 64 KiB in size.

> is it just like a DOS .exe but with no header?

NO, DOS MZ .EXE uses org 0, DOS .COM uses org $0100, MZ can be > 64 KiB, .COM can't.

> i have heard it is emulated, is that true?

NO (you can fraud everything not necessarily excluding DOS executables, but there is no such a "feature" of DOS .COM).

> whats the real difference of use a DOS .exe or a .com file?

See above.

smiddy wrote:
Microsoft describes it with a great level of detail here: http://support.macrosoft.com/kb/65122


NO. This text refers to Win16 NE EXE, not to DOS or DOS .COM at all. Evil or Very Mad

BTW, the DOS subforum has a FAQ covering also this problem Wink
Post 28 Jan 2010, 06:17
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 28 Jan 2010, 15:23
Thanks guys.

a little question: what's the diference of format PE console to format MZ?
Post 28 Jan 2010, 15:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20516
Location: In your JS exploiting you and your system
revolution 28 Jan 2010, 15:33
format PE console: Win32 program, 32bit.

format MZ: DOS program, 16bit.

A big difference.
Post 28 Jan 2010, 15:33
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 28 Jan 2010, 17:30
The "PE" format is another different format than MZ (DOS .exe), but it has a short "DOS-stub" at the beginning that, if run by DOS, should display a message such as "This program cannot be run in DOS mode" and exit.

The actual PE format and header follows after that.
Post 28 Jan 2010, 17:30
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 28 Jan 2010, 19:48
DOS386 wrote:
NO. This text refers to Win16 NE EXE, not to DOS or DOS .COM at all. Evil or Very Mad


Ouch, are you seriously pissed? I thought it has a description of legacy EXE format. I didn't realize anyone would be offended by that.


Last edited by smiddy on 28 Jan 2010, 22:02; edited 1 time in total
Post 28 Jan 2010, 19:48
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 28 Jan 2010, 20:13
DOS386, did you know that your joke link redirects to a credit card site? (probably of phishing-like purposes for doing such practices)
Post 28 Jan 2010, 20:13
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1905
DOS386 29 Jan 2010, 10:37
smiddy wrote:
DOS386 wrote:
NO. This text refers to Win16 NE EXE, not to DOS or DOS .COM at all. Evil or Very Mad


Ouch, are you seriously pissed?


NO

Quote:
thought it has a description of legacy EXE format.


Next time study link content before boasting with it. It's legacy NE, not "legacy" DOS MZ - the MZ stub is only there to output stupid hint "Macrosoft windows is required".

Quote:
I didn't realize anyone would be offended by that.


Next time just avoid "arguments" like pissed, especially if YOU are wrong.

Quote:
a little question: what's the diference of format PE console to format MZ?


MZ : DOS executable, use INT $21 + other INT's

PE : usually Win32 executable, use imports + API, no INT's

but also:

PE : a PE-based 32-bit DOS extender, use INT $21 + other INT's, but care about protected mode http://board.flatassembler.net/topic.php?t=8670 !!!

Quote:
that your joke link redirects to a credit card


COOL Laughing

BTW: NE, LE, LX and PE formats are hacked "on the top" of MZ (good design, isn't it Idea ???), while ELF isn't Shocked
Post 29 Jan 2010, 10:37
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 29 Jan 2010, 11:48
Ah I see, it is not ok to ever be wrong...the spirit of this place is to learn (wrong being so absolute, which my post wasn't entirely wrong, it was a further perspective). You are not very encouraging. I never boasted...I simply offered details on an EXE executable, which are realavent to the discussion.
Post 29 Jan 2010, 11:48
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 29 Jan 2010, 17:23
Quote:

Next time just avoid "arguments" like pissed, especially if YOU are wrong.

What he should say instead? Confused

What amount of unneeded rudeness BTW...

Also, since you seek for perfection many thanks for not editing your joke link so we can still help that probably malicious site to get more hits...
Post 29 Jan 2010, 17:23
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 29 Jan 2010, 19:23
Chill out guys.
Post 29 Jan 2010, 19:23
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 29 Jan 2010, 19:54
Sometimes DOS386 will SHOUT at us
but its ok, he is just trying to help in his own way...
We are all friends here so forget about anything like that.
Post 29 Jan 2010, 19:54
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1905
DOS386 30 Jan 2010, 09:58
LocoDelAssembly wrote:
What amount of unneeded rudeness BTW...


Who ? Some moderator other than me or Loco please fix or kill this thread ... for me it's done, EOD
Post 30 Jan 2010, 09:58
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 30 Jan 2010, 10:10
edited by a now sober sinsi...apologies

dos386 has an agenda, who knows what it is.
Late to answer, shouting, 'I know and you dont', and this person is a mod? sorry, the dos forum has gone downhill recently...


Nice fucking link you wanker.
Sick of your narrow-minded I-know-best crap.

I agree, some responsible mod should kill this thread.


Last edited by sinsi on 30 Jan 2010, 23:46; edited 1 time in total
Post 30 Jan 2010, 10:10
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 30 Jan 2010, 16:41
Quote:

and this person is a mod? sorry, the dos forum has gone downhill recently...
His work moderating DOS forum is excellent, just look at the elaborate FAQ he made.

His participation on this thread is the part that I don't like the most...
Post 30 Jan 2010, 16:41
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.