flat assembler
Message board for the users of flat assembler.

Index > DOS > the difference between exe and com

Author
Thread Post new topic Reply to topic
nvictor



Joined: 17 Feb 2007
Posts: 31
nvictor
well after some googling this is what I've found:

- a binary file format is composed of four parts : a file header, a number of sections, a relocation table and a symbol table.

- DOS EXE is a BFF holding the signature MZ in his file header, a number of sections and a relocation table.

Well I don't know much about sections, tables and symbol, but one thing I've read in FASM programmer reference is the format MZ directive that ouputs MZ binary files.

Interesting, that's the way of writing exe files...
Post 18 Feb 2007, 13:44
View user's profile Send private message Reply with quote
nvictor



Joined: 17 Feb 2007
Posts: 31
nvictor
[updated]

Final code ...

Code:
format MZ

        push cs
        pop ds        
        mov ah,9
        mov dx,message
        int 21h
        mov ax,4c00h
        int 21h

message db 'Hello World!',24h     


push cs : store cs address on stack
pop ds : store cs address in ds

It's like cs = ds

But I don't know why we must do that!
Post 18 Feb 2007, 14:29
View user's profile Send private message Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
nvictor wrote:

push cs : store cs address on stack
pop ds : store cs address in ds

It's like cs = ds

But I don't know why we must do that!

Intel is responsible for that, it's because of the x86 instruction arcitecture.

In short, there is no machine code for "mov cs,ds"
Post 18 Feb 2007, 17:56
View user's profile Send private message Reply with quote
nvictor



Joined: 17 Feb 2007
Posts: 31
nvictor
[update]
nevermind. int 21h need ds:dx to store value of our string.

[old]
MCD,
yes; but why do we do that? why not leave cs and ds like they were? I tried and there was garbage before the actual "hello World!" That's what I don't undertand.
Post 18 Feb 2007, 18:01
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
A segment is 64k big, and hence a .COM file itself can be no bigger (actually, about 65100 bytes or so). To get around this segmentation limit, you use more than one segment. .EXEs can be a lot bigger than 64k (e.g. DJGPP, 32-bit pmode, has some that are > 1 MB), and as such you must tell it explicitly what to do. It's all a relic of old (usually pre-386) memory management. (Someone please explain this better than me if I described it incorrectly.)
Post 18 Feb 2007, 20:35
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
Quote:
binary file format is composed of four parts : a file header, a number of sections, a relocation table and a symbol table.


Very limited usability of this info for DOS Confused

Quote:
DOS EXE is a BFF holding the signature MZ in his file header, a number of sections and a relocation table


There are no sections in DOS MZ-EXE. It was probably a Win32-PE EXE.

Quote:
Well I don't know much about sections, tables and symbol


Forget about them for DOS development with FASM Laughing

Quote:
I've read in FASM programmer reference is the format MZ directive that ouputs MZ binary files.


YES. Important Smile

Quote:
Interesting, that's the way of writing exe files...


Not only:

http://board.flatassembler.net/topic.php?t=6735

Quote:
get around this segmentation limit, you use more than one segment. .EXEs can be a lot bigger than 64k (e.g. DJGPP, 32-bit pmode, has some that are > 1 MB)


<64 KB: One segment EXE or COM (multiseg possible but not useful)

64 KB ... cca 400 KB: MZ-EXE, multiseg, with relocs or other workaround

cca 400 KB ... cca 1 MB: MZ-EXE with MZ overlay (obsolete, very bad)

Huge: 32-bit DOS, use DPMI / DOS extender, many MB possible

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug


Last edited by DOS386 on 22 Feb 2007, 05:06; edited 1 time in total
Post 19 Feb 2007, 12:54
View user's profile Send private message Reply with quote
yumka



Joined: 09 Feb 2007
Posts: 38
Location: Tenochtitlan
yumka
Look at MAME DOS for an example of huge DOS executable.

The last time i saw it was arround 10 MB.

Crazy, crazy, crazy!

It should be optimised with fasm. Wink
Post 19 Feb 2007, 19:24
View user's profile Send private message Visit poster's website Reply with quote
zir_blazer



Joined: 05 Dec 2006
Posts: 66
zir_blazer
yumka wrote:
Look at MAME DOS for an example of huge DOS executable.

The last time i saw it was arround 10 MB.

Crazy, crazy, crazy!

It should be optimised with fasm. Wink

If it was in FASM, not only it would be smaller, but it would be FASTER. There are a whole bunch of games that requieres everything that you can get, an example is the ancient but still ass kicking Gauntler Legends.
Good examples of Console Emulators in x86 Assembler includes ZSNES for SNES and NeoRageX for NeoGeo, those both were capable of emulating games in real time that with other emulators done in high level languages you usually requiere TWICE the machine for archieving the same results. DOSBox in FASM would also be ass kicking.
Post 19 Feb 2007, 21:44
View user's profile Send private message MSN Messenger Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
NO$GMB (not written by me) was written in assembly, that's why it ran full-speed even on my old 486.

BTW, I think MAME.EXE is 36 MB (or so) but compressed to 8 MB w/ UPX. Laughing
Post 20 Feb 2007, 05:14
View user's profile Send private message Visit poster's website Reply with quote
yumka



Joined: 09 Feb 2007
Posts: 38
Location: Tenochtitlan
yumka
Some MAME CPU's core are written in assembler, but in my opĂ­nion they are lost. An All-Arcade (games) simulator is a insane way to go.

You need to read all MB of exe to load a driver for CPU, sound, video and game specific. I mean read 35 Mb to use maybe 2 mb is not a effient solution. They should split it in many DLL, so you load 1 dll for CPU, 1 for sound, 1 for Video, 1 for MAME Core, and the specific game driver.
Post 20 Feb 2007, 20:53
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
yumka: I think DLL files have quite a lot overhead and are not portable.

when deciding between C and ASM, you decide between portability and performace... It's sad decision one way or another...
Post 20 Feb 2007, 21:28
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
yumka



Joined: 09 Feb 2007
Posts: 38
Location: Tenochtitlan
yumka
Yea you are right.

ld could make shared libraries for unix (.so) and for windows (.dll)

But i don't know if that breaks compatibity with other MAME ports. At least with DOS they are not feasible.

I suppose there must be a reason why all those programmers haven't adopted another model.
Post 20 Feb 2007, 22:16
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
yumka wrote:
Yea you are right.

ld could make shared libraries for unix (.so) and for windows (.dll)

But i don't know if that breaks compatibity with other MAME ports. At least with DOS they are not feasible.

I suppose there must be a reason why all those programmers haven't adopted another model.


There are several ways to (supposedly) make .DLLs (or something very close in functionality) in DOS, but I've never tried 'em. Someone ask Japheth for his opinion! *buzz* Smile
Post 20 Feb 2007, 22:29
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
rugxulo: actually, there were DLLs in DOS. Some borland stuff
Post 20 Feb 2007, 23:15
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
I meant that they aren't easily coded or used much (besides WDOS/X or DJGPP's EMU387.DXE).
Post 20 Feb 2007, 23:32
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.